home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 April: System Software / Dev.CD Apr 95 / Dev.CD Apr 95.toast / What's New? / Technical Documentation / Inside Macintosh / IM—Thread Manager (Draft) / IM—Thread Manager < prev   
MacBinary  |  1995-02-21  |  876.6 KB  |  [ONLN/HLX2]

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: MacBinary (archive/macBinary).

ConfidenceProgramDetectionMatch TypeSupport
10% dexvert MacBinary (archive/macBinary) fallback Supported
100% file MacBinary II, inited, Mon Feb 6 05:21:48 1995, modified Tue Feb 21 14:27:11 1995, creator 'HLX2', type 'ONLN', 879996 bytes "IM�Thread Manager" , at 0xd6dfc 17444 bytes resource default (weak)
99% file data default
100% TrID MacBinary 2 default (weak)
50% lsar MacBinary default


id metadata
keyvalue
macFileType[ONLN]
macFileCreator[HLX2]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 11 49 4d d1 54 68 72 | 65 61 64 20 4d 61 6e 61 |..IM.Thr|ead Mana|
|00000010| 67 65 72 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |ger.....|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 4f 4e 4c 4e 48 4c 58 | 32 01 00 00 00 00 00 00 |.ONLNHLX|2.......|
|00000050| 00 00 00 00 0d 6d 7c 00 | 00 44 24 ab 5b a8 bc ab |.....m|.|.D$.[...|
|00000060| 6f ef 0f 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |o.......|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 e7 89 00 00 |........|........|
|00000080| 49 6e 73 69 64 65 20 4d | 61 63 69 6e 74 6f 73 68 |Inside M|acintosh|
|00000090| 0d 0d 0d 0d 54 68 72 65 | 61 64 20 4d 61 6e 61 67 |....Thre|ad Manag|
|000000a0| 65 72 0d f0 09 41 70 70 | 6c 65 20 43 6f 6d 70 75 |er...App|le Compu|
|000000b0| 74 65 72 2c 20 49 6e 63 | 2e 0d a9 20 31 39 39 35 |ter, Inc|... 1995|
|000000c0| 20 41 70 70 6c 65 20 43 | 6f 6d 70 75 74 65 72 2c | Apple C|omputer,|
|000000d0| 20 49 6e 63 2e 0d 41 6c | 6c 20 72 69 67 68 74 73 | Inc..Al|l rights|
|000000e0| 20 72 65 73 65 72 76 65 | 64 2e 20 0d 4e 6f 20 70 | reserve|d. .No p|
|000000f0| 61 72 74 20 6f 66 20 74 | 68 69 73 20 70 75 62 6c |art of t|his publ|
|00000100| 69 63 61 74 69 6f 6e 20 | 6d 61 79 20 62 65 20 72 |ication |may be r|
|00000110| 65 70 72 6f 64 75 63 65 | 64 2c 20 73 74 6f 72 65 |eproduce|d, store|
|00000120| 64 20 69 6e 20 61 20 72 | 65 74 72 69 65 76 61 6c |d in a r|etrieval|
|00000130| 20 73 79 73 74 65 6d 2c | 20 6f 72 20 74 72 61 6e | system,| or tran|
|00000140| 73 6d 69 74 74 65 64 2c | 20 69 6e 20 61 6e 79 20 |smitted,| in any |
|00000150| 66 6f 72 6d 20 6f 72 20 | 62 79 20 61 6e 79 20 6d |form or |by any m|
|00000160| 65 61 6e 73 2c 20 6d 65 | 63 68 61 6e 69 63 61 6c |eans, me|chanical|
|00000170| 2c 20 65 6c 65 63 74 72 | 6f 6e 69 63 2c 20 70 68 |, electr|onic, ph|
|00000180| 6f 74 6f 63 6f 70 79 69 | 6e 67 2c 20 72 65 63 6f |otocopyi|ng, reco|
|00000190| 72 64 69 6e 67 2c 20 6f | 72 20 6f 74 68 65 72 77 |rding, o|r otherw|
|000001a0| 69 73 65 2c 20 77 69 74 | 68 6f 75 74 20 70 72 69 |ise, wit|hout pri|
|000001b0| 6f 72 20 77 72 69 74 74 | 65 6e 20 70 65 72 6d 69 |or writt|en permi|
|000001c0| 73 73 69 6f 6e 20 6f 66 | 20 41 70 70 6c 65 20 43 |ssion of| Apple C|
|000001d0| 6f 6d 70 75 74 65 72 2c | 20 49 6e 63 2e 0d 54 68 |omputer,| Inc..Th|
|000001e0| 65 20 41 70 70 6c 65 20 | 6c 6f 67 6f 20 69 73 20 |e Apple |logo is |
|000001f0| 61 20 74 72 61 64 65 6d | 61 72 6b 20 6f 66 20 0d |a tradem|ark of .|
|00000200| 41 70 70 6c 65 20 43 6f | 6d 70 75 74 65 72 2c 20 |Apple Co|mputer, |
|00000210| 49 6e 63 2e 20 0d 55 73 | 65 20 6f 66 20 74 68 65 |Inc. .Us|e of the|
|00000220| 20 d2 6b 65 79 62 6f 61 | 72 64 d3 20 41 70 70 6c | .keyboa|rd. Appl|
|00000230| 65 20 6c 6f 67 6f 20 28 | 4f 70 74 69 6f 6e 2d 53 |e logo (|Option-S|
|00000240| 68 69 66 74 2d 4b 29 20 | 66 6f 72 20 63 6f 6d 6d |hift-K) |for comm|
|00000250| 65 72 63 69 61 6c 20 70 | 75 72 70 6f 73 65 73 20 |ercial p|urposes |
|00000260| 77 69 74 68 6f 75 74 20 | 74 68 65 20 70 72 69 6f |without |the prio|
|00000270| 72 20 77 72 69 74 74 65 | 6e 20 63 6f 6e 73 65 6e |r writte|n consen|
|00000280| 74 20 6f 66 20 41 70 70 | 6c 65 20 6d 61 79 20 63 |t of App|le may c|
|00000290| 6f 6e 73 74 69 74 75 74 | 65 20 74 72 61 64 65 6d |onstitut|e tradem|
|000002a0| 61 72 6b 20 69 6e 66 72 | 69 6e 67 65 6d 65 6e 74 |ark infr|ingement|
|000002b0| 20 61 6e 64 20 75 6e 66 | 61 69 72 20 63 6f 6d 70 | and unf|air comp|
|000002c0| 65 74 69 74 69 6f 6e 20 | 69 6e 20 76 69 6f 6c 61 |etition |in viola|
|000002d0| 74 69 6f 6e 20 6f 66 20 | 66 65 64 65 72 61 6c 20 |tion of |federal |
|000002e0| 61 6e 64 20 73 74 61 74 | 65 20 6c 61 77 73 2e 20 |and stat|e laws. |
|000002f0| 0d 4e 6f 20 6c 69 63 65 | 6e 73 65 73 2c 20 65 78 |.No lice|nses, ex|
|00000300| 70 72 65 73 73 20 6f 72 | 20 69 6d 70 6c 69 65 64 |press or| implied|
|00000310| 2c 20 61 72 65 20 67 72 | 61 6e 74 65 64 20 77 69 |, are gr|anted wi|
|00000320| 74 68 20 72 65 73 70 65 | 63 74 20 74 6f 20 61 6e |th respe|ct to an|
|00000330| 79 20 6f 66 20 74 68 65 | 20 74 65 63 68 6e 6f 6c |y of the| technol|
|00000340| 6f 67 79 20 64 65 73 63 | 72 69 62 65 64 20 69 6e |ogy desc|ribed in|
|00000350| 20 74 68 69 73 20 62 6f | 6f 6b 2e 20 41 70 70 6c | this bo|ok. Appl|
|00000360| 65 20 72 65 74 61 69 6e | 73 20 61 6c 6c 20 69 6e |e retain|s all in|
|00000370| 74 65 6c 6c 65 63 74 75 | 61 6c 20 70 72 6f 70 65 |tellectu|al prope|
|00000380| 72 74 79 20 72 69 67 68 | 74 73 20 61 73 73 6f 63 |rty righ|ts assoc|
|00000390| 69 61 74 65 64 20 77 69 | 74 68 20 74 68 65 20 74 |iated wi|th the t|
|000003a0| 65 63 68 6e 6f 6c 6f 67 | 79 20 64 65 73 63 72 69 |echnolog|y descri|
|000003b0| 62 65 64 20 69 6e 20 74 | 68 69 73 20 62 6f 6f 6b |bed in t|his book|
|000003c0| 2e 20 54 68 69 73 20 62 | 6f 6f 6b 20 69 73 20 69 |. This b|ook is i|
|000003d0| 6e 74 65 6e 64 65 64 20 | 74 6f 20 61 73 73 69 73 |ntended |to assis|
|000003e0| 74 20 61 70 70 6c 69 63 | 61 74 69 6f 6e 20 64 65 |t applic|ation de|
|000003f0| 76 65 6c 6f 70 65 72 73 | 20 74 6f 20 64 65 76 65 |velopers| to deve|
|00000400| 6c 6f 70 20 61 70 70 6c | 69 63 61 74 69 6f 6e 73 |lop appl|ications|
|00000410| 20 6f 6e 6c 79 20 66 6f | 72 20 41 70 70 6c 65 20 | only fo|r Apple |
|00000420| 4d 61 63 69 6e 74 6f 73 | 68 20 63 6f 6d 70 75 74 |Macintos|h comput|
|00000430| 65 72 73 2e 0d 45 76 65 | 72 79 20 65 66 66 6f 72 |ers..Eve|ry effor|
|00000440| 74 20 68 61 73 20 62 65 | 65 6e 20 6d 61 64 65 20 |t has be|en made |
|00000450| 74 6f 20 65 6e 73 75 72 | 65 20 74 68 61 74 20 74 |to ensur|e that t|
|00000460| 68 65 20 69 6e 66 6f 72 | 6d 61 74 69 6f 6e 20 69 |he infor|mation i|
|00000470| 6e 20 74 68 69 73 20 6d | 61 6e 75 61 6c 20 69 73 |n this m|anual is|
|00000480| 20 61 63 63 75 72 61 74 | 65 2e 20 41 70 70 6c 65 | accurat|e. Apple|
|00000490| 20 69 73 20 6e 6f 74 20 | 72 65 73 70 6f 6e 73 69 | is not |responsi|
|000004a0| 62 6c 65 20 66 6f 72 20 | 74 79 70 6f 67 72 61 70 |ble for |typograp|
|000004b0| 68 69 63 61 6c 20 65 72 | 72 6f 72 73 2e 0d 41 70 |hical er|rors..Ap|
|000004c0| 70 6c 65 20 43 6f 6d 70 | 75 74 65 72 2c 20 49 6e |ple Comp|uter, In|
|000004d0| 63 2e 0d 31 20 49 6e 66 | 69 6e 69 74 65 20 4c 6f |c..1 Inf|inite Lo|
|000004e0| 6f 70 0d 43 75 70 65 72 | 74 69 6e 6f 2c 20 43 41 |op.Cuper|tino, CA|
|000004f0| 20 39 35 30 31 34 0d 34 | 30 38 2d 39 39 36 2d 31 | 95014.4|08-996-1|
|00000500| 30 31 30 0d 41 70 70 6c | 65 2c 20 74 68 65 20 41 |010.Appl|e, the A|
|00000510| 70 70 6c 65 20 6c 6f 67 | 6f 2c 20 41 50 44 41 2c |pple log|o, APDA,|
|00000520| 20 61 6e 64 20 4d 61 63 | 69 6e 74 6f 73 68 20 61 | and Mac|intosh a|
|00000530| 72 65 20 74 72 61 64 65 | 6d 61 72 6b 73 20 6f 66 |re trade|marks of|
|00000540| 20 41 70 70 6c 65 20 43 | 6f 6d 70 75 74 65 72 2c | Apple C|omputer,|
|00000550| 20 49 6e 63 2e 2c 20 72 | 65 67 69 73 74 65 72 65 | Inc., r|egistere|
|00000560| 64 20 69 6e 20 74 68 65 | 20 55 6e 69 74 65 64 20 |d in the| United |
|00000570| 53 74 61 74 65 73 20 61 | 6e 64 20 6f 74 68 65 72 |States a|nd other|
|00000580| 20 63 6f 75 6e 74 72 69 | 65 73 2e 0d 4f 70 65 6e | countri|es..Open|
|00000590| 44 6f 63 20 69 73 20 61 | 20 74 72 61 64 65 6d 61 |Doc is a| tradema|
|000005a0| 72 6b 20 6f 66 20 41 70 | 70 6c 65 20 43 6f 6d 70 |rk of Ap|ple Comp|
|000005b0| 75 74 65 72 2c 20 49 6e | 63 2e 0d 41 64 6f 62 65 |uter, In|c..Adobe|
|000005c0| 20 49 6c 6c 75 73 74 72 | 61 74 6f 72 20 61 6e 64 | Illustr|ator and|
|000005d0| 20 41 64 6f 62 65 20 50 | 68 6f 74 6f 73 68 6f 70 | Adobe P|hotoshop|
|000005e0| 20 61 72 65 20 74 72 61 | 64 65 6d 61 72 6b 73 20 | are tra|demarks |
|000005f0| 6f 66 20 41 64 6f 62 65 | 20 53 79 73 74 65 6d 73 |of Adobe| Systems|
|00000600| 20 49 6e 63 6f 72 70 6f | 72 61 74 65 64 2c 20 77 | Incorpo|rated, w|
|00000610| 68 69 63 68 20 6d 61 79 | 20 62 65 20 72 65 67 69 |hich may| be regi|
|00000620| 73 74 65 72 65 64 20 69 | 6e 20 63 65 72 74 61 69 |stered i|n certai|
|00000630| 6e 20 6a 75 72 69 73 64 | 69 63 74 69 6f 6e 73 2e |n jurisd|ictions.|
|00000640| 0d 41 6d 65 72 69 63 61 | 20 4f 6e 6c 69 6e 65 20 |.America| Online |
|00000650| 69 73 20 61 20 72 65 67 | 69 73 74 65 72 65 64 20 |is a reg|istered |
|00000660| 73 65 72 76 69 63 65 20 | 6d 61 72 6b 20 6f 66 20 |service |mark of |
|00000670| 41 6d 65 72 69 63 61 20 | 4f 6e 6c 69 6e 65 2c 20 |America |Online, |
|00000680| 49 6e 63 2e 0d 43 6f 6d | 70 75 53 65 72 76 65 20 |Inc..Com|puServe |
|00000690| 69 73 20 61 20 72 65 67 | 69 73 74 65 72 65 64 20 |is a reg|istered |
|000006a0| 73 65 72 76 69 63 65 20 | 6d 61 72 6b 20 6f 66 20 |service |mark of |
|000006b0| 43 6f 6d 70 75 53 65 72 | 76 65 2c 20 49 6e 63 2e |CompuSer|ve, Inc.|
|000006c0| 0d 46 72 61 6d 65 4d 61 | 6b 65 72 20 69 73 20 61 |.FrameMa|ker is a|
|000006d0| 20 72 65 67 69 73 74 65 | 72 65 64 20 74 72 61 64 | registe|red trad|
|000006e0| 65 6d 61 72 6b 20 6f 66 | 20 46 72 61 6d 65 20 54 |emark of| Frame T|
|000006f0| 65 63 68 6e 6f 6c 6f 67 | 79 20 43 6f 72 70 6f 72 |echnolog|y Corpor|
|00000700| 61 74 69 6f 6e 2e 0d 48 | 65 6c 76 65 74 69 63 61 |ation..H|elvetica|
|00000710| 20 61 6e 64 20 50 61 6c | 61 74 69 6e 6f 20 61 72 | and Pal|atino ar|
|00000720| 65 20 72 65 67 69 73 74 | 65 72 65 64 20 74 72 61 |e regist|ered tra|
|00000730| 64 65 6d 61 72 6b 73 20 | 6f 66 20 4c 69 6e 6f 74 |demarks |of Linot|
|00000740| 79 70 65 20 43 6f 6d 70 | 61 6e 79 2e 0d 49 54 43 |ype Comp|any..ITC|
|00000750| 20 5a 61 70 66 20 44 69 | 6e 67 62 61 74 73 20 69 | Zapf Di|ngbats i|
|00000760| 73 20 61 20 72 65 67 69 | 73 74 65 72 65 64 20 74 |s a regi|stered t|
|00000770| 72 61 64 65 6d 61 72 6b | 20 6f 66 20 49 6e 74 65 |rademark| of Inte|
|00000780| 72 6e 61 74 69 6f 6e 61 | 6c 20 54 79 70 65 66 61 |rnationa|l Typefa|
|00000790| 63 65 20 43 6f 72 70 6f | 72 61 74 69 6f 6e 2e 0d |ce Corpo|ration..|
|000007a0| 53 69 6d 75 6c 74 61 6e | 65 6f 75 73 6c 79 20 70 |Simultan|eously p|
|000007b0| 75 62 6c 69 73 68 65 64 | 20 69 6e 20 74 68 65 20 |ublished| in the |
|000007c0| 55 6e 69 74 65 64 20 53 | 74 61 74 65 73 20 61 6e |United S|tates an|
|000007d0| 64 20 43 61 6e 61 64 61 | 2e 0d 5b 44 65 6c 65 74 |d Canada|..[Delet|
|000007e0| 65 20 62 72 61 63 6b 65 | 74 65 64 20 69 6e 73 74 |e bracke|ted inst|
|000007f0| 72 75 63 74 69 6f 6e 73 | 20 62 65 66 6f 72 65 20 |ructions| before |
|00000800| 70 72 69 6e 74 69 6e 67 | 2e 0d 41 64 64 20 61 70 |printing|..Add ap|
|00000810| 70 6c 69 63 61 62 6c 65 | 20 41 70 70 6c 65 20 72 |plicable| Apple r|
|00000820| 65 67 69 73 74 65 72 65 | 64 20 74 72 61 64 65 6d |egistere|d tradem|
|00000830| 61 72 6b 73 20 28 a8 d5 | 73 29 20 74 6f 20 74 68 |arks (..|s) to th|
|00000840| 65 20 6e 69 6e 74 68 20 | 70 61 72 61 67 72 61 70 |e ninth |paragrap|
|00000850| 68 2e 0d 49 66 20 79 6f | 75 72 20 62 6f 6f 6b 20 |h..If yo|ur book |
|00000860| 6d 65 6e 74 69 6f 6e 73 | 20 41 70 70 6c 65 20 74 |mentions| Apple t|
|00000870| 72 61 64 65 6d 61 72 6b | 73 20 28 aa d5 73 29 2c |rademark|s (..s),|
|00000880| 20 61 64 64 20 61 20 63 | 72 65 64 69 74 20 70 61 | add a c|redit pa|
|00000890| 72 61 67 72 61 70 68 20 | 61 66 74 65 72 20 74 68 |ragraph |after th|
|000008a0| 65 20 6e 69 6e 74 68 20 | 70 61 72 61 67 72 61 70 |e ninth |paragrap|
|000008b0| 68 3a 20 d2 4e 61 6d 65 | 20 61 6e 64 20 4e 61 6d |h: .Name| and Nam|
|000008c0| 65 20 61 72 65 20 74 72 | 61 64 65 6d 61 72 6b 73 |e are tr|ademarks|
|000008d0| 20 6f 66 20 41 70 70 6c | 65 20 43 6f 6d 70 75 74 | of Appl|e Comput|
|000008e0| 65 72 2c 20 49 6e 63 2e | d3 0d 41 64 64 20 61 70 |er, Inc.|..Add ap|
|000008f0| 70 72 6f 70 72 69 61 74 | 65 20 74 68 69 72 64 20 |propriat|e third |
|00000900| 70 61 72 74 79 20 74 72 | 61 64 65 6d 61 72 6b 73 |party tr|ademarks|
|00000910| 2e 0d 49 66 20 79 6f 75 | d5 72 65 20 6e 6f 74 20 |..If you|.re not |
|00000920| 75 73 69 6e 67 20 74 68 | 65 20 63 6f 6c 6f 70 68 |using th|e coloph|
|00000930| 6f 6e 20 28 69 6e 20 61 | 20 73 65 65 64 20 6e 6f |on (in a| seed no|
|00000940| 74 65 2c 20 66 6f 72 20 | 65 78 61 6d 70 6c 65 29 |te, for |example)|
|00000950| 2c 20 64 65 6c 65 74 65 | 20 74 68 65 20 74 72 61 |, delete| the tra|
|00000960| 64 65 6d 61 72 6b 20 63 | 72 65 64 69 74 73 20 74 |demark c|redits t|
|00000970| 68 61 74 20 61 70 70 6c | 79 20 74 6f 20 74 68 65 |hat appl|y to the|
|00000980| 20 63 6f 6c 6f 70 68 6f | 6e 2c 20 69 66 20 74 68 | colopho|n, if th|
|00000990| 61 74 d5 73 20 74 68 65 | 20 6f 6e 6c 79 20 70 6c |at.s the| only pl|
|000009a0| 61 63 65 20 74 68 65 20 | 74 72 61 64 65 6d 61 72 |ace the |trademar|
|000009b0| 6b 73 20 61 72 65 20 6d | 65 6e 74 69 6f 6e 65 64 |ks are m|entioned|
|000009c0| 20 28 4c 61 73 65 72 57 | 72 69 74 65 72 2c 20 4d | (LaserW|riter, M|
|000009d0| 61 63 69 6e 74 6f 73 68 | 2c 20 49 6c 6c 75 73 74 |acintosh|, Illust|
|000009e0| 72 61 74 6f 72 20 70 61 | 72 61 67 72 61 70 68 2c |rator pa|ragraph,|
|000009f0| 20 46 72 61 6d 65 4d 61 | 6b 65 72 20 70 61 72 61 | FrameMa|ker para|
|00000a00| 67 72 61 70 68 2c 20 48 | 65 6c 76 65 74 69 63 61 |graph, H|elvetica|
|00000a10| 20 70 61 72 61 67 72 61 | 70 68 2c 20 49 54 43 20 | paragra|ph, ITC |
|00000a20| 70 61 72 61 67 72 61 70 | 68 2c 20 44 6f 63 75 74 |paragrap|h, Docut|
|00000a30| 65 6b 2c 20 61 6e 64 20 | 4f 70 74 72 6f 74 65 63 |ek, and |Optrotec|
|00000a40| 68 20 70 61 72 61 67 72 | 61 70 68 73 29 2e 0d 45 |h paragr|aphs)..E|
|00000a50| 76 65 6e 20 74 68 6f 75 | 67 68 20 41 70 70 6c 65 |ven thou|gh Apple|
|00000a60| 20 68 61 73 20 72 65 76 | 69 65 77 65 64 20 74 68 | has rev|iewed th|
|00000a70| 69 73 20 6d 61 6e 75 61 | 6c 2c 20 41 50 50 4c 45 |is manua|l, APPLE|
|00000a80| 20 4d 41 4b 45 53 20 4e | 4f 20 57 41 52 52 41 4e | MAKES N|O WARRAN|
|00000a90| 54 59 20 4f 52 20 52 45 | 50 52 45 53 45 4e 54 41 |TY OR RE|PRESENTA|
|00000aa0| 54 49 4f 4e 2c 20 45 49 | 54 48 45 52 20 45 58 50 |TION, EI|THER EXP|
|00000ab0| 52 45 53 53 20 4f 52 20 | 49 4d 50 4c 49 45 44 2c |RESS OR |IMPLIED,|
|00000ac0| 20 57 49 54 48 20 52 45 | 53 50 45 43 54 20 54 4f | WITH RE|SPECT TO|
|00000ad0| 20 54 48 49 53 20 4d 41 | 4e 55 41 4c 2c 20 49 54 | THIS MA|NUAL, IT|
|00000ae0| 53 20 51 55 41 4c 49 54 | 59 2c 20 41 43 43 55 52 |S QUALIT|Y, ACCUR|
|00000af0| 41 43 59 2c 20 4d 45 52 | 43 48 41 4e 54 41 42 49 |ACY, MER|CHANTABI|
|00000b00| 4c 49 54 59 2c 20 4f 52 | 20 46 49 54 4e 45 53 53 |LITY, OR| FITNESS|
|00000b10| 20 46 4f 52 20 41 20 50 | 41 52 54 49 43 55 4c 41 | FOR A P|ARTICULA|
|00000b20| 52 20 50 55 52 50 4f 53 | 45 2e 20 41 53 20 41 20 |R PURPOS|E. AS A |
|00000b30| 52 45 53 55 4c 54 2c 20 | 54 48 49 53 20 4d 41 4e |RESULT, |THIS MAN|
|00000b40| 55 41 4c 20 49 53 20 53 | 4f 4c 44 20 d2 41 53 20 |UAL IS S|OLD .AS |
|00000b50| 49 53 2c d3 20 41 4e 44 | 20 59 4f 55 2c 20 54 48 |IS,. AND| YOU, TH|
|00000b60| 45 20 50 55 52 43 48 41 | 53 45 52 2c 20 41 52 45 |E PURCHA|SER, ARE|
|00000b70| 20 41 53 53 55 4d 49 4e | 47 20 54 48 45 20 45 4e | ASSUMIN|G THE EN|
|00000b80| 54 49 52 45 20 52 49 53 | 4b 20 41 53 20 54 4f 20 |TIRE RIS|K AS TO |
|00000b90| 49 54 53 20 51 55 41 4c | 49 54 59 20 41 4e 44 20 |ITS QUAL|ITY AND |
|00000ba0| 41 43 43 55 52 41 43 59 | 2e 0d 49 4e 20 4e 4f 20 |ACCURACY|..IN NO |
|00000bb0| 45 56 45 4e 54 20 57 49 | 4c 4c 20 41 50 50 4c 45 |EVENT WI|LL APPLE|
|00000bc0| 20 42 45 20 4c 49 41 42 | 4c 45 20 46 4f 52 20 44 | BE LIAB|LE FOR D|
|00000bd0| 49 52 45 43 54 2c 20 49 | 4e 44 49 52 45 43 54 2c |IRECT, I|NDIRECT,|
|00000be0| 20 53 50 45 43 49 41 4c | 2c 20 49 4e 43 49 44 45 | SPECIAL|, INCIDE|
|00000bf0| 4e 54 41 4c 2c 20 4f 52 | 20 43 4f 4e 53 45 51 55 |NTAL, OR| CONSEQU|
|00000c00| 45 4e 54 49 41 4c 20 44 | 41 4d 41 47 45 53 20 52 |ENTIAL D|AMAGES R|
|00000c10| 45 53 55 4c 54 49 4e 47 | 20 46 52 4f 4d 20 41 4e |ESULTING| FROM AN|
|00000c20| 59 20 44 45 46 45 43 54 | 20 4f 52 20 49 4e 41 43 |Y DEFECT| OR INAC|
|00000c30| 43 55 52 41 43 59 20 49 | 4e 20 54 48 49 53 20 4d |CURACY I|N THIS M|
|00000c40| 41 4e 55 41 4c 2c 20 65 | 76 65 6e 20 69 66 20 61 |ANUAL, e|ven if a|
|00000c50| 64 76 69 73 65 64 20 6f | 66 20 74 68 65 20 70 6f |dvised o|f the po|
|00000c60| 73 73 69 62 69 6c 69 74 | 79 20 6f 66 20 73 75 63 |ssibilit|y of suc|
|00000c70| 68 20 64 61 6d 61 67 65 | 73 2e 0d 54 48 45 20 57 |h damage|s..THE W|
|00000c80| 41 52 52 41 4e 54 59 20 | 41 4e 44 20 52 45 4d 45 |ARRANTY |AND REME|
|00000c90| 44 49 45 53 20 53 45 54 | 20 46 4f 52 54 48 20 41 |DIES SET| FORTH A|
|00000ca0| 42 4f 56 45 20 41 52 45 | 20 45 58 43 4c 55 53 49 |BOVE ARE| EXCLUSI|
|00000cb0| 56 45 20 41 4e 44 20 49 | 4e 20 4c 49 45 55 20 4f |VE AND I|N LIEU O|
|00000cc0| 46 20 41 4c 4c 20 4f 54 | 48 45 52 53 2c 20 4f 52 |F ALL OT|HERS, OR|
|00000cd0| 41 4c 20 4f 52 20 57 52 | 49 54 54 45 4e 2c 20 45 |AL OR WR|ITTEN, E|
|00000ce0| 58 50 52 45 53 53 20 4f | 52 20 49 4d 50 4c 49 45 |XPRESS O|R IMPLIE|
|00000cf0| 44 2e 20 4e 6f 20 41 70 | 70 6c 65 20 64 65 61 6c |D. No Ap|ple deal|
|00000d00| 65 72 2c 20 61 67 65 6e | 74 2c 20 6f 72 20 65 6d |er, agen|t, or em|
|00000d10| 70 6c 6f 79 65 65 20 69 | 73 20 61 75 74 68 6f 72 |ployee i|s author|
|00000d20| 69 7a 65 64 20 74 6f 20 | 6d 61 6b 65 20 61 6e 79 |ized to |make any|
|00000d30| 20 6d 6f 64 69 66 69 63 | 61 74 69 6f 6e 2c 20 65 | modific|ation, e|
|00000d40| 78 74 65 6e 73 69 6f 6e | 2c 20 6f 72 20 61 64 64 |xtension|, or add|
|00000d50| 69 74 69 6f 6e 20 74 6f | 20 74 68 69 73 20 77 61 |ition to| this wa|
|00000d60| 72 72 61 6e 74 79 2e 0d | 53 6f 6d 65 20 73 74 61 |rranty..|Some sta|
|00000d70| 74 65 73 20 64 6f 20 6e | 6f 74 20 61 6c 6c 6f 77 |tes do n|ot allow|
|00000d80| 20 74 68 65 20 65 78 63 | 6c 75 73 69 6f 6e 20 6f | the exc|lusion o|
|00000d90| 72 20 6c 69 6d 69 74 61 | 74 69 6f 6e 20 6f 66 20 |r limita|tion of |
|00000da0| 69 6d 70 6c 69 65 64 20 | 77 61 72 72 61 6e 74 69 |implied |warranti|
|00000db0| 65 73 20 6f 72 20 6c 69 | 61 62 69 6c 69 74 79 20 |es or li|ability |
|00000dc0| 66 6f 72 20 69 6e 63 69 | 64 65 6e 74 61 6c 20 6f |for inci|dental o|
|00000dd0| 72 20 63 6f 6e 73 65 71 | 75 65 6e 74 69 61 6c 20 |r conseq|uential |
|00000de0| 64 61 6d 61 67 65 73 2c | 20 73 6f 20 74 68 65 20 |damages,| so the |
|00000df0| 61 62 6f 76 65 20 6c 69 | 6d 69 74 61 74 69 6f 6e |above li|mitation|
|00000e00| 20 6f 72 20 65 78 63 6c | 75 73 69 6f 6e 20 6d 61 | or excl|usion ma|
|00000e10| 79 20 6e 6f 74 20 61 70 | 70 6c 79 20 74 6f 20 79 |y not ap|ply to y|
|00000e20| 6f 75 2e 20 54 68 69 73 | 20 77 61 72 72 61 6e 74 |ou. This| warrant|
|00000e30| 79 20 67 69 76 65 73 20 | 79 6f 75 20 73 70 65 63 |y gives |you spec|
|00000e40| 69 66 69 63 20 6c 65 67 | 61 6c 20 72 69 67 68 74 |ific leg|al right|
|00000e50| 73 2c 20 61 6e 64 20 79 | 6f 75 20 6d 61 79 20 61 |s, and y|ou may a|
|00000e60| 6c 73 6f 20 68 61 76 65 | 20 6f 74 68 65 72 20 72 |lso have| other r|
|00000e70| 69 67 68 74 73 20 77 68 | 69 63 68 20 76 61 72 79 |ights wh|ich vary|
|00000e80| 20 66 72 6f 6d 20 73 74 | 61 74 65 20 74 6f 20 73 | from st|ate to s|
|00000e90| 74 61 74 65 2e 0d 0d 54 | 68 72 65 61 64 20 4d 61 |tate...T|hread Ma|
|00000ea0| 6e 61 67 65 72 20 0d 43 | 6f 6e 74 65 6e 74 73 0d |nager .C|ontents.|
|00000eb0| 0d 49 6e 74 72 6f 64 75 | 63 74 69 6f 6e 20 74 6f |.Introdu|ction to|
|00000ec0| 20 54 68 72 65 61 64 73 | 20 33 0d 41 62 6f 75 74 | Threads| 3.About|
|00000ed0| 20 74 68 65 20 54 68 72 | 65 61 64 20 4d 61 6e 61 | the Thr|ead Mana|
|00000ee0| 67 65 72 20 34 0d 53 63 | 68 65 64 75 6c 69 6e 67 |ger 4.Sc|heduling|
|00000ef0| 20 35 0d 54 68 65 20 4d | 61 69 6e 20 54 68 72 65 | 5.The M|ain Thre|
|00000f00| 61 64 20 37 0d 43 75 73 | 74 6f 6d 20 53 63 68 65 |ad 7.Cus|tom Sche|
|00000f10| 64 75 6c 65 72 20 38 0d | 44 65 66 61 75 6c 74 20 |duler 8.|Default |
|00000f20| 53 61 76 65 64 20 54 68 | 72 65 61 64 20 43 6f 6e |Saved Th|read Con|
|00000f30| 74 65 78 74 20 39 0d 43 | 75 73 74 6f 6d 20 43 6f |text 9.C|ustom Co|
|00000f40| 6e 74 65 78 74 2d 53 77 | 69 74 63 68 69 6e 67 20 |ntext-Sw|itching |
|00000f50| 46 75 6e 63 74 69 6f 6e | 20 31 30 0d 54 68 72 65 |Function| 10.Thre|
|00000f60| 61 64 20 53 74 61 63 6b | 73 20 31 31 0d 43 72 65 |ad Stack|s 11.Cre|
|00000f70| 61 74 69 6e 67 20 61 6e | 64 20 44 69 73 70 6f 73 |ating an|d Dispos|
|00000f80| 69 6e 67 20 6f 66 20 54 | 68 72 65 61 64 73 20 31 |ing of T|hreads 1|
|00000f90| 32 0d 55 73 69 6e 67 20 | 74 68 65 20 54 68 72 65 |2.Using |the Thre|
|00000fa0| 61 64 20 4d 61 6e 61 67 | 65 72 20 31 32 0d 44 65 |ad Manag|er 12.De|
|00000fb0| 74 65 72 6d 69 6e 69 6e | 67 20 41 74 74 72 69 62 |terminin|g Attrib|
|00000fc0| 75 74 65 73 20 6f 66 20 | 74 68 65 20 54 68 72 65 |utes of |the Thre|
|00000fd0| 61 64 20 4d 61 6e 61 67 | 65 72 20 31 33 0d 43 72 |ad Manag|er 13.Cr|
|00000fe0| 65 61 74 69 6e 67 20 61 | 6e 64 20 41 6c 6c 6f 63 |eating a|nd Alloc|
|00000ff0| 61 74 69 6e 67 20 61 20 | 54 68 72 65 61 64 20 31 |ating a |Thread 1|
|00001000| 33 0d 43 72 65 61 74 69 | 6e 67 20 61 20 50 6f 6f |3.Creati|ng a Poo|
|00001010| 6c 20 6f 66 20 54 68 72 | 65 61 64 73 20 31 35 0d |l of Thr|eads 15.|
|00001020| 41 6c 6c 6f 63 61 74 69 | 6e 67 20 61 20 54 68 72 |Allocati|ng a Thr|
|00001030| 65 61 64 20 31 36 0d 54 | 75 72 6e 69 6e 67 20 53 |ead 16.T|urning S|
|00001040| 63 68 65 64 75 6c 69 6e | 67 20 4f 66 66 20 32 30 |chedulin|g Off 20|
|00001050| 0d 57 6f 72 6b 69 6e 67 | 20 57 69 74 68 20 53 74 |.Working| With St|
|00001060| 61 63 6b 73 20 32 31 0d | 43 72 65 61 74 69 6e 67 |acks 21.|Creating|
|00001070| 20 44 69 61 6c 6f 67 20 | 42 6f 78 65 73 20 54 68 | Dialog |Boxes Th|
|00001080| 61 74 20 59 69 65 6c 64 | 20 32 33 0d 50 61 73 73 |at Yield| 23.Pass|
|00001090| 69 6e 67 20 49 6e 70 75 | 74 20 61 6e 64 20 4f 75 |ing Inpu|t and Ou|
|000010a0| 74 70 75 74 20 50 61 72 | 61 6d 65 74 65 72 73 20 |tput Par|ameters |
|000010b0| 74 6f 20 61 20 4e 65 77 | 20 54 68 72 65 61 64 20 |to a New| Thread |
|000010c0| 32 34 0d 55 73 69 6e 67 | 20 54 68 72 65 61 64 73 |24.Using| Threads|
|000010d0| 20 57 69 74 68 20 49 2f | 4f 20 32 37 0d 43 6f 6e | With I/|O 27.Con|
|000010e0| 76 65 72 74 69 6e 67 20 | 50 72 65 65 6d 70 74 69 |verting |Preempti|
|000010f0| 76 65 20 54 68 72 65 61 | 64 73 20 74 6f 20 43 6f |ve Threa|ds to Co|
|00001100| 6f 70 65 72 61 74 69 76 | 65 20 54 68 72 65 61 64 |operativ|e Thread|
|00001110| 73 20 33 34 0d 54 68 72 | 65 61 64 20 4d 61 6e 61 |s 34.Thr|ead Mana|
|00001120| 67 65 72 20 52 65 66 65 | 72 65 6e 63 65 20 33 34 |ger Refe|rence 34|
|00001130| 0d 44 61 74 61 20 54 79 | 70 65 73 20 33 34 0d 47 |.Data Ty|pes 34.G|
|00001140| 65 73 74 61 6c 74 20 53 | 65 6c 65 63 74 6f 72 20 |estalt S|elector |
|00001150| 61 6e 64 20 52 65 73 70 | 6f 6e 73 65 20 42 69 74 |and Resp|onse Bit|
|00001160| 73 20 33 34 0d 54 68 65 | 20 54 68 72 65 61 64 20 |s 34.The| Thread |
|00001170| 53 74 61 74 65 20 33 35 | 0d 54 68 65 20 54 68 72 |State 35|.The Thr|
|00001180| 65 61 64 20 54 61 73 6b | 20 52 65 66 65 72 65 6e |ead Task| Referen|
|00001190| 63 65 20 33 35 0d 54 68 | 65 20 54 68 72 65 61 64 |ce 35.Th|e Thread|
|000011a0| 20 54 79 70 65 20 33 36 | 0d 54 68 65 20 54 68 72 | Type 36|.The Thr|
|000011b0| 65 61 64 20 49 44 20 33 | 36 0d 54 68 72 65 61 64 |ead ID 3|6.Thread|
|000011c0| 20 4f 70 74 69 6f 6e 73 | 20 33 37 0d 54 68 65 20 | Options| 37.The |
|000011d0| 53 63 68 65 64 75 6c 65 | 72 20 49 6e 66 6f 72 6d |Schedule|r Inform|
|000011e0| 61 74 69 6f 6e 20 53 74 | 72 75 63 74 75 72 65 20 |ation St|ructure |
|000011f0| 33 38 0d 54 68 72 65 61 | 64 20 4d 61 6e 61 67 65 |38.Threa|d Manage|
|00001200| 72 20 46 75 6e 63 74 69 | 6f 6e 73 20 33 38 0d 43 |r Functi|ons 38.C|
|00001210| 72 65 61 74 69 6e 67 20 | 61 6e 64 20 47 65 74 74 |reating |and Gett|
|00001220| 69 6e 67 20 49 6e 66 6f | 72 6d 61 74 69 6f 6e 20 |ing Info|rmation |
|00001230| 41 62 6f 75 74 20 54 68 | 72 65 61 64 20 50 6f 6f |About Th|read Poo|
|00001240| 6c 73 20 33 39 0d 43 72 | 65 61 74 69 6e 67 20 61 |ls 39.Cr|eating a|
|00001250| 6e 64 20 44 69 73 70 6f | 73 69 6e 67 20 6f 66 20 |nd Dispo|sing of |
|00001260| 54 68 72 65 61 64 73 20 | 34 34 0d 47 65 74 74 69 |Threads |44.Getti|
|00001270| 6e 67 20 49 6e 66 6f 72 | 6d 61 74 69 6f 6e 20 41 |ng Infor|mation A|
|00001280| 62 6f 75 74 20 53 70 65 | 63 69 66 69 63 20 54 68 |bout Spe|cific Th|
|00001290| 72 65 61 64 73 20 34 37 | 0d 53 63 68 65 64 75 6c |reads 47|.Schedul|
|000012a0| 69 6e 67 20 54 68 72 65 | 61 64 73 20 35 30 0d 50 |ing Thre|ads 50.P|
|000012b0| 72 65 76 65 6e 74 69 6e | 67 20 53 63 68 65 64 75 |reventin|g Schedu|
|000012c0| 6c 69 6e 67 20 35 34 0d | 47 65 74 74 69 6e 67 20 |ling 54.|Getting |
|000012d0| 49 6e 66 6f 72 6d 61 74 | 69 6f 6e 20 61 6e 64 20 |Informat|ion and |
|000012e0| 53 63 68 65 64 75 6c 69 | 6e 67 20 54 68 72 65 61 |Scheduli|ng Threa|
|000012f0| 64 73 20 44 75 72 69 6e | 67 20 49 6e 74 65 72 72 |ds Durin|g Interr|
|00001300| 75 70 74 73 20 35 37 0d | 49 6e 73 74 61 6c 6c 69 |upts 57.|Installi|
|00001310| 6e 67 20 43 75 73 74 6f | 6d 20 53 63 68 65 64 75 |ng Custo|m Schedu|
|00001320| 6c 69 6e 67 2c 20 53 77 | 69 74 63 68 69 6e 67 2c |ling, Sw|itching,|
|00001330| 20 54 65 72 6d 69 6e 61 | 74 69 6e 67 2c 20 61 6e | Termina|ting, an|
|00001340| 64 20 44 65 62 75 67 67 | 69 6e 67 20 46 75 6e 63 |d Debugg|ing Func|
|00001350| 74 69 6f 6e 73 20 36 31 | 0d 41 70 70 6c 69 63 61 |tions 61|.Applica|
|00001360| 74 69 6f 6e 2d 44 65 66 | 69 6e 65 64 20 52 6f 75 |tion-Def|ined Rou|
|00001370| 74 69 6e 65 73 20 36 37 | 0d 53 75 6d 6d 61 72 79 |tines 67|.Summary|
|00001380| 20 6f 66 20 74 68 65 20 | 54 68 72 65 61 64 20 4d | of the |Thread M|
|00001390| 61 6e 61 67 65 72 20 37 | 33 0d 0d 54 68 72 65 61 |anager 7|3..Threa|
|000013a0| 64 20 4d 61 6e 61 67 65 | 72 0d 0d 54 68 69 73 20 |d Manage|r..This |
|000013b0| 63 68 61 70 74 65 72 20 | 64 65 73 63 72 69 62 65 |chapter |describe|
|000013c0| 73 20 68 6f 77 20 79 6f | 75 20 63 61 6e 20 75 73 |s how yo|u can us|
|000013d0| 65 20 74 68 65 20 54 68 | 72 65 61 64 20 4d 61 6e |e the Th|read Man|
|000013e0| 61 67 65 72 20 74 6f 20 | 70 72 6f 76 69 64 65 20 |ager to |provide |
|000013f0| 74 68 72 65 61 64 73 2c | 20 6f 72 20 6d 75 6c 74 |threads,| or mult|
|00001400| 69 70 6c 65 20 70 6f 69 | 6e 74 73 20 6f 66 20 65 |iple poi|nts of e|
|00001410| 78 65 63 75 74 69 6f 6e | 2c 20 69 6e 20 61 6e 20 |xecution|, in an |
|00001420| 61 70 70 6c 69 63 61 74 | 69 6f 6e 2e 20 59 6f 75 |applicat|ion. You|
|00001430| 20 63 61 6e 20 74 68 69 | 6e 6b 20 6f 66 20 74 68 | can thi|nk of th|
|00001440| 65 20 54 68 72 65 61 64 | 20 4d 61 6e 61 67 65 72 |e Thread| Manager|
|00001450| 20 61 73 20 61 6e 20 65 | 6e 68 61 6e 63 65 6d 65 | as an e|nhanceme|
|00001460| 6e 74 20 74 6f 20 74 68 | 65 20 50 72 6f 63 65 73 |nt to th|e Proces|
|00001470| 73 20 4d 61 6e 61 67 65 | 72 2c 20 77 68 69 63 68 |s Manage|r, which|
|00001480| 20 73 74 69 6c 6c 20 67 | 6f 76 65 72 6e 73 20 68 | still g|overns h|
|00001490| 6f 77 20 61 70 70 6c 69 | 63 61 74 69 6f 6e 73 20 |ow appli|cations |
|000014a0| 77 6f 72 6b 20 74 6f 67 | 65 74 68 65 72 20 69 6e |work tog|ether in|
|000014b0| 20 74 68 65 20 4d 61 63 | 69 6e 74 6f 73 68 20 6d | the Mac|intosh m|
|000014c0| 75 6c 74 69 74 61 73 6b | 69 6e 67 20 65 6e 76 69 |ultitask|ing envi|
|000014d0| 72 6f 6e 6d 65 6e 74 2e | 20 54 68 65 72 65 66 6f |ronment.| Therefo|
|000014e0| 72 65 2c 20 79 6f 75 20 | 73 68 6f 75 6c 64 20 61 |re, you |should a|
|000014f0| 6c 72 65 61 64 79 20 62 | 65 20 66 61 6d 69 6c 69 |lready b|e famili|
|00001500| 61 72 20 77 69 74 68 20 | 74 68 65 20 63 6f 6e 63 |ar with |the conc|
|00001510| 65 70 74 73 20 69 6e 20 | 49 6e 73 69 64 65 20 4d |epts in |Inside M|
|00001520| 61 63 69 6e 74 6f 73 68 | 3a 20 50 72 6f 63 65 73 |acintosh|: Proces|
|00001530| 73 65 73 20 61 6e 64 20 | 49 6e 73 69 64 65 20 4d |ses and |Inside M|
|00001540| 61 63 69 6e 74 6f 73 68 | 3a 20 4d 65 6d 6f 72 79 |acintosh|: Memory|
|00001550| 20 62 65 66 6f 72 65 20 | 72 65 61 64 69 6e 67 20 | before |reading |
|00001560| 74 68 69 73 20 63 68 61 | 70 74 65 72 2e 0d 52 65 |this cha|pter..Re|
|00001570| 61 64 20 74 68 69 73 20 | 63 68 61 70 74 65 72 20 |ad this |chapter |
|00001580| 69 66 20 79 6f 75 20 61 | 72 65 20 69 6e 74 65 72 |if you a|re inter|
|00001590| 65 73 74 65 64 20 69 6e | 20 64 65 76 65 6c 6f 70 |ested in| develop|
|000015a0| 69 6e 67 20 61 6e 20 61 | 70 70 6c 69 63 61 74 69 |ing an a|pplicati|
|000015b0| 6f 6e 20 77 69 74 68 20 | 6d 6f 72 65 20 74 68 61 |on with |more tha|
|000015c0| 6e 20 6f 6e 65 20 74 68 | 72 65 61 64 20 28 63 61 |n one th|read (ca|
|000015d0| 6c 6c 65 64 20 61 20 74 | 68 72 65 61 64 65 64 20 |lled a t|hreaded |
|000015e0| 61 70 70 6c 69 63 61 74 | 69 6f 6e 20 69 6e 20 74 |applicat|ion in t|
|000015f0| 68 69 73 20 64 6f 63 75 | 6d 65 6e 74 29 2e 20 49 |his docu|ment). I|
|00001600| 66 20 79 6f 75 72 20 61 | 70 70 6c 69 63 61 74 69 |f your a|pplicati|
|00001610| 6f 6e 20 75 73 65 73 20 | 6e 6f 20 54 68 72 65 61 |on uses |no Threa|
|00001620| 64 20 4d 61 6e 61 67 65 | 72 20 66 75 6e 63 74 69 |d Manage|r functi|
|00001630| 6f 6e 73 2c 20 74 68 65 | 20 50 72 6f 63 65 73 73 |ons, the| Process|
|00001640| 20 4d 61 6e 61 67 65 72 | 20 74 72 65 61 74 73 20 | Manager| treats |
|00001650| 69 74 20 61 73 20 61 20 | 73 69 6e 67 6c 65 2d 74 |it as a |single-t|
|00001660| 68 72 65 61 64 65 64 20 | 61 70 70 6c 69 63 61 74 |hreaded |applicat|
|00001670| 69 6f 6e 20 28 63 61 6c | 6c 65 64 20 61 20 6e 6f |ion (cal|led a no|
|00001680| 6e 74 68 72 65 61 64 65 | 64 20 61 70 70 6c 69 63 |nthreade|d applic|
|00001690| 61 74 69 6f 6e 20 69 6e | 20 74 68 69 73 20 64 6f |ation in| this do|
|000016a0| 63 75 6d 65 6e 74 29 2e | 54 68 65 20 50 72 6f 63 |cument).|The Proc|
|000016b0| 65 73 73 20 4d 61 6e 61 | 67 65 72 20 64 6f 65 73 |ess Mana|ger does|
|000016c0| 20 63 61 6c 6c 20 74 68 | 65 20 54 68 72 65 61 64 | call th|e Thread|
|000016d0| 20 4d 61 6e 61 67 65 72 | 20 61 74 20 6c 61 75 6e | Manager| at laun|
|000016e0| 63 68 20 74 69 6d 65 20 | 74 6f 20 63 72 65 61 74 |ch time |to creat|
|000016f0| 65 20 74 68 65 20 6d 61 | 69 6e 20 74 68 72 65 61 |e the ma|in threa|
|00001700| 64 20 66 6f 72 20 74 68 | 65 20 61 70 70 6c 69 63 |d for th|e applic|
|00001710| 61 74 69 6f 6e 2c 20 62 | 75 74 20 69 74 20 64 6f |ation, b|ut it do|
|00001720| 65 73 20 74 68 69 73 20 | 74 72 61 6e 73 70 61 72 |es this |transpar|
|00001730| 65 6e 74 6c 79 20 61 6e | 64 20 69 6e 20 6e 6f 20 |ently an|d in no |
|00001740| 77 61 79 20 61 66 66 65 | 63 74 73 20 74 68 65 20 |way affe|cts the |
|00001750| 70 65 72 66 6f 72 6d 61 | 6e 63 65 20 6f 66 20 79 |performa|nce of y|
|00001760| 6f 75 72 20 61 70 70 6c | 69 63 61 74 69 6f 6e 2e |our appl|ication.|
|00001770| 0d 54 68 69 73 20 63 68 | 61 70 74 65 72 20 62 65 |.This ch|apter be|
|00001780| 67 69 6e 73 20 62 79 20 | 64 65 73 63 72 69 62 69 |gins by |describi|
|00001790| 6e 67 20 74 68 65 20 61 | 64 76 61 6e 74 61 67 65 |ng the a|dvantage|
|000017a0| 73 20 6f 66 20 75 73 69 | 6e 67 20 74 68 72 65 61 |s of usi|ng threa|
|000017b0| 64 73 20 77 69 74 68 69 | 6e 20 61 6e 20 61 70 70 |ds withi|n an app|
|000017c0| 6c 69 63 61 74 69 6f 6e | 20 63 6f 6e 74 65 78 74 |lication| context|
|000017d0| 2e 20 49 74 20 64 65 73 | 63 72 69 62 65 73 20 74 |. It des|cribes t|
|000017e0| 68 65 20 73 63 68 65 64 | 75 6c 69 6e 67 20 6d 6f |he sched|uling mo|
|000017f0| 64 65 6c 20 74 68 61 74 | 20 74 68 65 20 54 68 72 |del that| the Thr|
|00001800| 65 61 64 20 6d 61 6e 61 | 67 65 72 20 70 72 6f 76 |ead mana|ger prov|
|00001810| 69 64 65 73 2c 20 74 68 | 65 20 63 6f 6e 74 65 78 |ides, th|e contex|
|00001820| 74 20 69 6e 66 6f 72 6d | 61 74 69 6f 6e 20 74 68 |t inform|ation th|
|00001830| 61 74 20 74 68 65 20 54 | 68 72 65 61 64 20 4d 61 |at the T|hread Ma|
|00001840| 6e 61 67 65 72 20 73 61 | 76 65 73 20 77 68 65 6e |nager sa|ves when|
|00001850| 20 69 74 20 73 77 69 74 | 63 68 65 73 20 6f 6e 65 | it swit|ches one|
|00001860| 20 74 68 72 65 61 64 20 | 6f 75 74 20 61 6e 64 20 | thread |out and |
|00001870| 61 6e 6f 74 68 65 72 20 | 6f 6e 65 20 69 6e 2c 20 |another |one in, |
|00001880| 61 6e 64 20 69 74 20 64 | 65 73 63 72 69 62 65 73 |and it d|escribes|
|00001890| 20 74 68 72 65 61 64 20 | 73 74 61 63 6b 73 2e 20 | thread |stacks. |
|000018a0| 49 74 20 74 68 65 6e 20 | 73 68 6f 77 73 20 68 6f |It then |shows ho|
|000018b0| 77 20 74 6f 0d 6e 09 63 | 72 65 61 74 65 20 74 68 |w to.n.c|reate th|
|000018c0| 72 65 61 64 73 20 61 6e | 64 20 74 68 72 65 61 64 |reads an|d thread|
|000018d0| 20 70 6f 6f 6c 73 20 61 | 6e 64 20 73 65 74 20 74 | pools a|nd set t|
|000018e0| 68 65 6d 20 75 70 20 74 | 6f 20 72 75 6e 0d 6e 09 |hem up t|o run.n.|
|000018f0| 74 75 72 6e 20 73 63 68 | 65 64 75 6c 69 6e 67 20 |turn sch|eduling |
|00001900| 6f 6e 20 61 6e 64 20 6f | 66 66 0d 6e 09 77 6f 72 |on and o|ff.n.wor|
|00001910| 6b 20 77 69 74 68 20 73 | 74 61 63 6b 73 0d 6e 09 |k with s|tacks.n.|
|00001920| 63 72 65 61 74 65 20 64 | 69 61 6c 6f 67 20 62 6f |create d|ialog bo|
|00001930| 78 65 73 20 74 68 61 74 | 20 79 69 65 6c 64 20 63 |xes that| yield c|
|00001940| 6f 6e 74 72 6f 6c 20 74 | 6f 20 6f 74 68 65 72 20 |ontrol t|o other |
|00001950| 74 68 72 65 61 64 73 0d | 6e 09 70 61 73 73 20 69 |threads.|n.pass i|
|00001960| 6e 66 6f 72 6d 61 74 69 | 6f 6e 20 62 65 74 77 65 |nformati|on betwe|
|00001970| 65 6e 20 74 68 72 65 61 | 64 73 0d 6e 09 69 6e 73 |en threa|ds.n.ins|
|00001980| 74 61 6c 6c 20 63 75 73 | 74 6f 6d 20 73 63 68 65 |tall cus|tom sche|
|00001990| 64 75 6c 69 6e 67 20 61 | 6e 64 20 63 6f 6e 74 65 |duling a|nd conte|
|000019a0| 78 74 2d 73 77 69 74 63 | 68 69 6e 67 20 66 75 6e |xt-switc|hing fun|
|000019b0| 63 74 69 6f 6e 73 0d 6e | 09 75 73 65 20 74 68 72 |ctions.n|.use thr|
|000019c0| 65 61 64 73 20 74 6f 20 | 6d 61 6b 65 20 61 73 79 |eads to |make asy|
|000019d0| 6e 63 68 72 6f 6e 6f 75 | 73 20 49 2f 4f 20 63 61 |nchronou|s I/O ca|
|000019e0| 6c 6c 73 0d 0d 49 6e 74 | 72 6f 64 75 63 74 69 6f |lls..Int|roductio|
|000019f0| 6e 20 74 6f 20 54 68 72 | 65 61 64 73 0d 0d 54 68 |n to Thr|eads..Th|
|00001a00| 72 65 61 64 73 2c 20 61 | 6c 73 6f 20 6b 6e 6f 77 |reads, a|lso know|
|00001a10| 6e 20 61 73 20 6c 69 67 | 68 74 77 65 69 67 68 74 |n as lig|htweight|
|00001a20| 20 74 61 73 6b 73 2c 20 | 61 72 65 20 61 20 77 61 | tasks, |are a wa|
|00001a30| 79 20 74 6f 20 64 65 76 | 65 6c 6f 70 20 63 6f 6e |y to dev|elop con|
|00001a40| 63 75 72 72 65 6e 63 79 | 2c 20 6f 72 20 6d 75 6c |currency|, or mul|
|00001a50| 74 69 70 6c 65 20 70 6f | 69 6e 74 73 20 6f 66 20 |tiple po|ints of |
|00001a60| 65 78 65 63 75 74 69 6f | 6e 2c 20 77 69 74 68 69 |executio|n, withi|
|00001a70| 6e 20 61 20 70 61 72 74 | 69 63 75 6c 61 72 20 63 |n a part|icular c|
|00001a80| 6f 6e 74 65 78 74 2c 20 | 73 75 63 68 20 61 73 20 |ontext, |such as |
|00001a90| 69 6e 20 61 6e 20 6f 70 | 65 72 61 74 69 6e 67 20 |in an op|erating |
|00001aa0| 73 79 73 74 65 6d 20 6f | 72 20 61 70 70 6c 69 63 |system o|r applic|
|00001ab0| 61 74 69 6f 6e 2e 20 54 | 68 65 20 54 68 72 65 61 |ation. T|he Threa|
|00001ac0| 64 20 4d 61 6e 61 67 65 | 72 20 6f 66 66 65 72 73 |d Manage|r offers|
|00001ad0| 20 74 68 72 65 61 64 73 | 20 66 6f 72 20 75 73 65 | threads| for use|
|00001ae0| 20 77 69 74 68 69 6e 20 | 61 6e 20 61 70 70 6c 69 | within |an appli|
|00001af0| 63 61 74 69 6f 6e 20 63 | 6f 6e 74 65 78 74 20 6f |cation c|ontext o|
|00001b00| 6e 6c 79 2e 20 49 74 20 | 64 6f 65 73 20 6e 6f 74 |nly. It |does not|
|00001b10| 20 70 72 6f 76 69 64 65 | 20 74 68 72 65 61 64 73 | provide| threads|
|00001b20| 20 74 6f 20 62 65 20 75 | 73 65 64 20 6f 6e 20 61 | to be u|sed on a|
|00001b30| 20 73 79 73 74 65 6d 77 | 69 64 65 20 62 61 73 69 | systemw|ide basi|
|00001b40| 73 2e 0d 54 68 72 65 61 | 64 73 20 6f 66 66 65 72 |s..Threa|ds offer|
|00001b50| 20 61 20 6e 65 77 20 61 | 6e 64 20 62 65 74 74 65 | a new a|nd bette|
|00001b60| 72 20 77 61 79 20 74 6f | 20 73 74 72 75 63 74 75 |r way to| structu|
|00001b70| 72 65 20 61 70 70 6c 69 | 63 61 74 69 6f 6e 73 20 |re appli|cations |
|00001b80| 66 6f 72 20 73 69 6d 70 | 6c 69 63 69 74 79 2c 20 |for simp|licity, |
|00001b90| 65 66 66 69 63 69 65 6e | 63 79 2c 20 61 6e 64 20 |efficien|cy, and |
|00001ba0| 72 65 73 70 6f 6e 73 69 | 76 65 6e 65 73 73 2e 20 |responsi|veness. |
|00001bb0| 57 69 74 68 20 6d 75 6c | 74 69 70 6c 65 20 70 6f |With mul|tiple po|
|00001bc0| 69 6e 74 73 20 6f 66 20 | 65 78 65 63 75 74 69 6f |ints of |executio|
|00001bd0| 6e 2c 20 79 6f 75 20 63 | 61 6e 20 64 6f 20 74 68 |n, you c|an do th|
|00001be0| 69 6e 67 73 20 73 75 63 | 68 20 61 73 20 0d 6e 09 |ings suc|h as .n.|
|00001bf0| 73 65 70 61 72 61 74 65 | 20 74 68 65 20 75 73 65 |separate| the use|
|00001c00| 72 20 69 6e 74 65 72 66 | 61 63 65 20 66 72 6f 6d |r interf|ace from|
|00001c10| 20 74 69 6d 65 2d 63 6f | 6e 73 75 6d 69 6e 67 20 | time-co|nsuming |
|00001c20| 74 61 73 6b 73 20 74 6f | 20 67 75 61 72 61 6e 74 |tasks to| guarant|
|00001c30| 65 65 20 72 65 73 70 6f | 6e 73 69 76 65 6e 65 73 |ee respo|nsivenes|
|00001c40| 73 20 74 6f 20 74 68 65 | 20 75 73 65 72 0d 6e 09 |s to the| user.n.|
|00001c50| 70 6c 61 63 65 20 61 20 | 6d 6f 64 61 6c 20 64 69 |place a |modal di|
|00001c60| 61 6c 6f 67 20 62 6f 78 | 20 69 6e 20 6f 6e 65 20 |alog box| in one |
|00001c70| 74 68 72 65 61 64 20 61 | 6e 64 20 61 20 66 75 6e |thread a|nd a fun|
|00001c80| 63 74 69 6f 6e 20 74 6f | 20 70 72 6f 63 65 73 73 |ction to| process|
|00001c90| 20 64 61 74 61 20 6f 72 | 20 70 65 72 66 6f 72 6d | data or| perform|
|00001ca0| 20 63 61 6c 63 75 6c 61 | 74 69 6f 6e 73 20 69 6e | calcula|tions in|
|00001cb0| 20 61 20 64 69 66 66 65 | 72 65 6e 74 20 74 68 72 | a diffe|rent thr|
|00001cc0| 65 61 64 20 73 6f 20 74 | 68 61 74 20 79 6f 75 72 |ead so t|hat your|
|00001cd0| 20 61 70 70 6c 69 63 61 | 74 69 6f 6e 20 63 61 6e | applica|tion can|
|00001ce0| 20 63 6f 6e 74 69 6e 75 | 65 20 77 6f 72 6b 69 6e | continu|e workin|
|00001cf0| 67 20 72 61 74 68 65 72 | 20 74 68 61 6e 20 73 69 |g rather| than si|
|00001d00| 74 74 69 6e 67 20 61 6e | 64 20 77 61 69 74 69 6e |tting an|d waitin|
|00001d10| 67 20 77 68 69 6c 65 20 | 61 20 75 73 65 72 20 64 |g while |a user d|
|00001d20| 65 63 69 64 65 73 20 77 | 68 69 63 68 20 63 68 6f |ecides w|hich cho|
|00001d30| 69 63 65 20 74 6f 20 6d | 61 6b 65 20 69 6e 20 74 |ice to m|ake in t|
|00001d40| 68 65 20 64 69 61 6c 6f | 67 20 62 6f 78 0d 6e 09 |he dialo|g box.n.|
|00001d50| 73 69 6d 70 6c 69 66 79 | 20 79 6f 75 72 20 63 6f |simplify| your co|
|00001d60| 64 65 20 62 79 20 70 6c | 61 63 69 6e 67 20 65 61 |de by pl|acing ea|
|00001d70| 63 68 20 65 6c 65 6d 65 | 6e 74 20 6f 66 20 61 20 |ch eleme|nt of a |
|00001d80| 73 69 6d 75 6c 61 74 69 | 6f 6e 20 69 6e 20 61 20 |simulati|on in a |
|00001d90| 73 65 70 61 72 61 74 65 | 20 74 68 72 65 61 64 20 |separate| thread |
|00001da0| 0d 6e 09 69 6e 63 72 65 | 61 73 65 20 74 68 65 20 |.n.incre|ase the |
|00001db0| 65 66 66 69 63 69 65 6e | 63 79 20 6f 66 20 79 6f |efficien|cy of yo|
|00001dc0| 75 72 20 61 70 70 6c 69 | 63 61 74 69 6f 6e 20 62 |ur appli|cation b|
|00001dd0| 79 20 65 6c 69 6d 69 6e | 61 74 69 6e 67 20 6d 61 |y elimin|ating ma|
|00001de0| 6e 79 20 56 42 4c 20 61 | 6e 64 20 54 69 6d 65 20 |ny VBL a|nd Time |
|00001df0| 4d 61 6e 61 67 65 72 20 | 74 61 73 6b 73 2e 0d 41 |Manager |tasks..A|
|00001e00| 6c 74 68 6f 75 67 68 20 | 79 6f 75 20 63 61 6e 20 |lthough |you can |
|00001e10| 61 6c 72 65 61 64 79 20 | 64 6f 20 6d 61 6e 79 20 |already |do many |
|00001e20| 6f 66 20 74 68 65 20 74 | 68 69 6e 67 73 20 74 68 |of the t|hings th|
|00001e30| 61 74 20 74 68 72 65 61 | 64 73 20 65 6e 61 62 6c |at threa|ds enabl|
|00001e40| 65 20 79 6f 75 20 74 6f | 20 64 6f 2c 20 74 68 65 |e you to| do, the|
|00001e50| 20 69 6d 70 6c 65 6d 65 | 6e 74 61 74 69 6f 6e 20 | impleme|ntation |
|00001e60| 77 69 74 68 6f 75 74 20 | 74 68 72 65 61 64 73 20 |without |threads |
|00001e70| 63 61 6e 20 62 65 20 64 | 69 66 66 69 63 75 6c 74 |can be d|ifficult|
|00001e80| 20 61 6e 64 20 69 6e 65 | 6c 65 67 61 6e 74 2e 20 | and ine|legant. |
|00001e90| 46 6f 72 20 65 78 61 6d | 70 6c 65 2c 20 77 69 74 |For exam|ple, wit|
|00001ea0| 68 20 6e 75 6c 6c 20 65 | 76 65 6e 74 73 20 61 74 |h null e|vents at|
|00001eb0| 20 69 64 6c 65 20 74 69 | 6d 65 20 79 6f 75 20 63 | idle ti|me you c|
|00001ec0| 61 6e 20 77 72 69 74 65 | 20 69 64 6c 65 2d 70 72 |an write| idle-pr|
|00001ed0| 6f 63 65 73 73 69 6e 67 | 20 70 72 6f 63 65 64 75 |ocessing| procedu|
|00001ee0| 72 65 73 20 74 68 61 74 | 20 62 72 69 6e 67 20 61 |res that| bring a|
|00001ef0| 20 6d 65 61 73 75 72 65 | 20 6f 66 20 63 6f 6e 63 | measure| of conc|
|00001f00| 75 72 72 65 6e 63 79 20 | 74 6f 20 79 6f 75 72 20 |urrency |to your |
|00001f10| 61 70 70 6c 69 63 61 74 | 69 6f 6e 2e 20 48 6f 77 |applicat|ion. How|
|00001f20| 65 76 65 72 2c 20 74 68 | 72 65 61 64 73 20 6f 66 |ever, th|reads of|
|00001f30| 66 65 72 20 6d 61 6e 79 | 20 61 64 76 61 6e 74 61 |fer many| advanta|
|00001f40| 67 65 73 20 6e 6f 74 20 | 61 76 61 69 6c 61 62 6c |ges not |availabl|
|00001f50| 65 20 77 69 74 68 20 6f | 74 68 65 72 20 6d 65 74 |e with o|ther met|
|00001f60| 68 6f 64 73 20 6f 66 20 | 61 63 68 69 65 76 69 6e |hods of |achievin|
|00001f70| 67 20 63 6f 6e 63 75 72 | 72 65 6e 63 79 20 69 6e |g concur|rency in|
|00001f80| 20 61 6e 20 61 70 70 6c | 69 63 61 74 69 6f 6e 20 | an appl|ication |
|00001f90| 70 72 6f 67 72 61 6d 2e | 20 0d 41 20 6d 61 6a 6f |program.| .A majo|
|00001fa0| 72 20 62 65 6e 65 66 69 | 74 20 6f 66 20 75 73 69 |r benefi|t of usi|
|00001fb0| 6e 67 20 74 68 72 65 61 | 64 73 20 69 73 20 74 68 |ng threa|ds is th|
|00001fc0| 61 74 20 79 6f 75 20 63 | 61 6e 20 65 6e 68 61 6e |at you c|an enhan|
|00001fd0| 63 65 20 74 68 65 20 6c | 6f 67 69 63 61 6c 20 73 |ce the l|ogical s|
|00001fe0| 74 72 75 63 74 75 72 65 | 20 6f 66 20 79 6f 75 72 |tructure| of your|
|00001ff0| 20 70 72 6f 67 72 61 6d | 2e 20 55 73 69 6e 67 20 | program|. Using |
|00002000| 74 68 72 65 61 64 73 20 | 69 73 20 69 6e 20 6d 61 |threads |is in ma|
|00002010| 6e 79 20 77 61 79 73 20 | 6c 69 6b 65 20 61 64 64 |ny ways |like add|
|00002020| 69 6e 67 20 61 6e 20 6f | 62 6a 65 63 74 20 6c 61 |ing an o|bject la|
|00002030| 79 65 72 20 74 6f 20 79 | 6f 75 72 20 70 72 6f 67 |yer to y|our prog|
|00002040| 72 61 6d 2e 20 46 6f 72 | 20 65 78 61 6d 70 6c 65 |ram. For| example|
|00002050| 2c 20 6f 6e 65 20 77 61 | 79 20 74 6f 20 77 72 69 |, one wa|y to wri|
|00002060| 74 65 20 61 20 74 72 61 | 66 66 69 63 20 73 69 6d |te a tra|ffic sim|
|00002070| 75 6c 61 74 69 6f 6e 20 | 70 72 6f 67 72 61 6d 20 |ulation |program |
|00002080| 69 73 20 74 6f 20 63 72 | 65 61 74 65 20 61 20 73 |is to cr|eate a s|
|00002090| 65 70 61 72 61 74 65 20 | 74 68 72 65 61 64 20 74 |eparate |thread t|
|000020a0| 6f 20 63 6f 6e 74 72 6f | 6c 20 65 61 63 68 20 65 |o contro|l each e|
|000020b0| 6c 65 6d 65 6e 74 20 6f | 66 20 74 68 65 20 73 69 |lement o|f the si|
|000020c0| 6d 75 6c 61 74 69 6f 6e | d1 74 68 61 74 20 69 73 |mulation|.that is|
|000020d0| 2c 20 74 68 65 20 74 72 | 61 66 66 69 63 20 73 69 |, the tr|affic si|
|000020e0| 67 6e 61 6c 73 20 61 6e | 64 20 74 68 65 20 69 6e |gnals an|d the in|
|000020f0| 64 69 76 69 64 75 61 6c | 20 63 61 72 73 2e 20 59 |dividual| cars. Y|
|00002100| 6f 75 20 63 6f 75 6c 64 | 20 74 68 69 6e 6b 20 6f |ou could| think o|
|00002110| 66 20 65 61 63 68 20 74 | 68 72 65 61 64 20 61 73 |f each t|hread as|
|00002120| 20 61 6e 20 6f 62 6a 65 | 63 74 20 77 69 74 68 20 | an obje|ct with |
|00002130| 70 61 72 74 69 63 75 6c | 61 72 20 63 61 70 61 62 |particul|ar capab|
|00002140| 69 6c 69 74 69 65 73 2e | 20 49 6e 20 61 6e 79 20 |ilities.| In any |
|00002150| 63 61 73 65 2c 20 70 72 | 6f 67 72 61 6d 73 20 77 |case, pr|ograms w|
|00002160| 69 74 68 20 74 68 72 65 | 61 64 73 20 61 72 65 20 |ith thre|ads are |
|00002170| 65 61 73 69 65 72 20 74 | 6f 20 77 72 69 74 65 20 |easier t|o write |
|00002180| 61 6e 64 20 6d 75 63 68 | 20 65 61 73 69 65 72 20 |and much| easier |
|00002190| 74 6f 20 75 6e 64 65 72 | 73 74 61 6e 64 20 74 68 |to under|stand th|
|000021a0| 61 6e 20 70 72 6f 67 72 | 61 6d 73 20 74 68 61 74 |an progr|ams that|
|000021b0| 20 61 63 68 69 65 76 65 | 20 63 6f 6e 63 75 72 72 | achieve| concurr|
|000021c0| 65 6e 63 79 20 69 6e 20 | 61 20 72 6f 75 6e 64 61 |ency in |a rounda|
|000021d0| 62 6f 75 74 20 66 61 73 | 68 69 6f 6e 2c 20 73 75 |bout fas|hion, su|
|000021e0| 63 68 20 61 73 20 75 73 | 69 6e 67 20 69 64 6c 65 |ch as us|ing idle|
|000021f0| 2d 70 72 6f 63 65 73 73 | 69 6e 67 20 70 72 6f 63 |-process|ing proc|
|00002200| 65 64 75 72 65 73 20 6f | 72 20 73 74 61 74 65 20 |edures o|r state |
|00002210| 6d 61 63 68 69 6e 65 73 | 2e 0d 41 20 74 68 72 65 |machines|..A thre|
|00002220| 61 64 20 63 6f 6e 73 69 | 73 74 73 20 6f 66 20 61 |ad consi|sts of a|
|00002230| 70 70 6c 69 63 61 74 69 | 6f 6e 20 63 6f 64 65 20 |pplicati|on code |
|00002240| 61 6e 64 20 74 68 65 20 | 70 72 6f 63 65 73 73 6f |and the |processo|
|00002250| 72 20 73 74 61 74 65 20 | 6f 72 20 63 6f 6e 74 65 |r state |or conte|
|00002260| 78 74 20 74 6f 20 65 78 | 65 63 75 74 65 20 69 74 |xt to ex|ecute it|
|00002270| 2e 20 54 68 65 20 74 68 | 72 65 61 64 20 63 6f 6e |. The th|read con|
|00002280| 74 65 78 74 20 63 6f 6e | 73 69 73 74 73 20 6f 66 |text con|sists of|
|00002290| 20 61 20 72 65 67 69 73 | 74 65 72 20 73 65 74 2c | a regis|ter set,|
|000022a0| 20 61 20 70 72 6f 67 72 | 61 6d 20 63 6f 75 6e 74 | a progr|am count|
|000022b0| 65 72 2c 20 61 6e 64 20 | 61 20 73 74 61 63 6b 2e |er, and |a stack.|
|000022c0| 20 45 61 63 68 20 74 68 | 72 65 61 64 20 73 68 61 | Each th|read sha|
|000022d0| 72 65 73 20 74 68 65 20 | 61 64 64 72 65 73 73 20 |res the |address |
|000022e0| 73 70 61 63 65 2c 20 66 | 69 6c 65 20 61 63 63 65 |space, f|ile acce|
|000022f0| 73 73 20 70 61 74 68 73 | 2c 20 61 6e 64 20 6f 74 |ss paths|, and ot|
|00002300| 68 65 72 20 73 79 73 74 | 65 6d 20 72 65 73 6f 75 |her syst|em resou|
|00002310| 72 63 65 73 20 6f 66 20 | 74 68 65 20 61 70 70 6c |rces of |the appl|
|00002320| 69 63 61 74 69 6f 6e 20 | 70 72 6f 63 65 73 73 20 |ication |process |
|00002330| 69 6e 20 77 68 69 63 68 | 20 69 74 20 72 75 6e 73 |in which| it runs|
|00002340| 2e 20 54 68 65 72 65 66 | 6f 72 65 2c 20 77 68 65 |. Theref|ore, whe|
|00002350| 6e 20 74 68 65 20 54 68 | 72 65 61 64 20 4d 61 6e |n the Th|read Man|
|00002360| 61 67 65 72 20 73 77 69 | 74 63 68 65 73 20 63 6f |ager swi|tches co|
|00002370| 6e 74 72 6f 6c 20 66 72 | 6f 6d 20 6f 6e 65 20 74 |ntrol fr|om one t|
|00002380| 68 72 65 61 64 20 74 6f | 20 61 6e 6f 74 68 65 72 |hread to| another|
|00002390| 2c 20 74 68 65 20 61 6d | 6f 75 6e 74 20 6f 66 20 |, the am|ount of |
|000023a0| 63 6f 6e 74 65 78 74 20 | 69 6e 66 6f 72 6d 61 74 |context |informat|
|000023b0| 69 6f 6e 20 69 74 20 6d | 75 73 74 20 73 61 76 65 |ion it m|ust save|
|000023c0| 20 69 73 20 72 65 6c 61 | 74 69 76 65 6c 79 20 73 | is rela|tively s|
|000023d0| 6d 61 6c 6c 20 61 6e 64 | 20 74 68 65 20 73 77 69 |mall and| the swi|
|000023e0| 74 63 68 20 69 73 20 6d | 75 63 68 20 66 61 73 74 |tch is m|uch fast|
|000023f0| 65 72 20 74 68 61 6e 20 | 74 68 61 74 20 62 65 74 |er than |that bet|
|00002400| 77 65 65 6e 20 61 70 70 | 6c 69 63 61 74 69 6f 6e |ween app|lication|
|00002410| 20 70 72 6f 63 65 73 73 | 65 73 2e 0d 0d 41 62 6f | process|es...Abo|
|00002420| 75 74 20 74 68 65 20 54 | 68 72 65 61 64 20 4d 61 |ut the T|hread Ma|
|00002430| 6e 61 67 65 72 0d 0d 54 | 68 65 20 54 68 72 65 61 |nager..T|he Threa|
|00002440| 64 20 4d 61 6e 61 67 65 | 72 20 6d 61 6e 61 67 65 |d Manage|r manage|
|00002450| 73 20 74 68 72 65 61 64 | 73 20 77 69 74 68 69 6e |s thread|s within|
|00002460| 20 61 6e 20 61 70 70 6c | 69 63 61 74 69 6f 6e 20 | an appl|ication |
|00002470| 63 6f 6e 74 65 78 74 2e | 20 49 74 20 70 72 6f 76 |context.| It prov|
|00002480| 69 64 65 73 20 72 6f 75 | 74 69 6e 65 73 20 74 6f |ides rou|tines to|
|00002490| 20 63 72 65 61 74 65 2c | 20 67 65 74 20 69 6e 66 | create,| get inf|
|000024a0| 6f 72 6d 61 74 69 6f 6e | 20 61 62 6f 75 74 2c 20 |ormation| about, |
|000024b0| 73 63 68 65 64 75 6c 65 | 2c 20 61 6e 64 20 64 69 |schedule|, and di|
|000024c0| 73 70 6f 73 65 20 6f 66 | 20 74 68 72 65 61 64 73 |spose of| threads|
|000024d0| 2e 20 54 68 65 20 50 72 | 6f 63 65 73 73 20 4d 61 |. The Pr|ocess Ma|
|000024e0| 6e 61 67 65 72 2c 20 6f | 6e 20 74 68 65 20 6f 74 |nager, o|n the ot|
|000024f0| 68 65 72 20 68 61 6e 64 | 2c 20 69 73 20 72 65 73 |her hand|, is res|
|00002500| 70 6f 6e 73 69 62 6c 65 | 20 66 6f 72 20 73 77 69 |ponsible| for swi|
|00002510| 74 63 68 69 6e 67 20 74 | 68 65 20 63 6f 6e 74 65 |tching t|he conte|
|00002520| 78 74 20 62 65 74 77 65 | 65 6e 20 76 61 72 69 6f |xt betwe|en vario|
|00002530| 75 73 20 61 70 70 6c 69 | 63 61 74 69 6f 6e 20 70 |us appli|cation p|
|00002540| 72 6f 63 65 73 73 65 73 | 20 77 69 74 68 69 6e 20 |rocesses| within |
|00002550| 74 68 65 20 4d 61 63 69 | 6e 74 6f 73 68 20 6d 75 |the Maci|ntosh mu|
|00002560| 6c 74 69 74 61 73 6b 69 | 6e 67 20 65 6e 76 69 72 |ltitaski|ng envir|
|00002570| 6f 6e 6d 65 6e 74 2e 20 | 46 69 67 75 72 65 20 31 |onment. |Figure 1|
|00002580| 2d 31 20 69 6c 6c 75 73 | 74 72 61 74 65 73 20 74 |-1 illus|trates t|
|00002590| 68 65 20 72 65 6c 61 74 | 69 6f 6e 73 68 69 70 20 |he relat|ionship |
|000025a0| 62 65 74 77 65 65 6e 20 | 74 68 65 20 54 68 72 65 |between |the Thre|
|000025b0| 61 64 20 4d 61 6e 61 67 | 65 72 20 61 6e 64 20 74 |ad Manag|er and t|
|000025c0| 68 65 20 50 72 6f 63 65 | 73 73 20 4d 61 6e 61 67 |he Proce|ss Manag|
|000025d0| 65 72 2e 0d 0d 46 69 67 | 75 72 65 20 31 2d 31 09 |er...Fig|ure 1-1.|
|000025e0| 0d 52 65 6c 61 74 69 6f | 6e 73 68 69 70 20 6f 66 |.Relatio|nship of|
|000025f0| 20 54 68 72 65 61 64 20 | 4d 61 6e 61 67 65 72 20 | Thread |Manager |
|00002600| 61 6e 64 20 50 72 6f 63 | 65 73 73 20 4d 61 6e 61 |and Proc|ess Mana|
|00002610| 67 65 72 0d 0d 54 68 72 | 65 61 64 73 20 69 6e 20 |ger..Thr|eads in |
|00002620| 61 6e 20 61 70 70 6c 69 | 63 61 74 69 6f 6e 20 61 |an appli|cation a|
|00002630| 72 65 20 61 76 61 69 6c | 61 62 6c 65 20 74 6f 20 |re avail|able to |
|00002640| 72 75 6e 20 6f 6e 6c 79 | 20 77 68 65 6e 20 74 68 |run only| when th|
|00002650| 65 20 50 72 6f 63 65 73 | 73 20 4d 61 6e 61 67 65 |e Proces|s Manage|
|00002660| 72 20 73 63 68 65 64 75 | 6c 65 73 20 74 68 65 20 |r schedu|les the |
|00002670| 61 70 70 6c 69 63 61 74 | 69 6f 6e 20 74 6f 20 72 |applicat|ion to r|
|00002680| 75 6e 2e 20 46 6f 72 20 | 65 78 61 6d 70 6c 65 2c |un. For |example,|
|00002690| 20 77 68 65 6e 20 74 68 | 65 20 50 72 6f 63 65 73 | when th|e Proces|
|000026a0| 73 20 4d 61 6e 61 67 65 | 72 73 20 73 77 69 74 63 |s Manage|rs switc|
|000026b0| 68 65 73 20 69 6e 20 61 | 70 70 6c 69 63 61 74 69 |hes in a|pplicati|
|000026c0| 6f 6e 20 41 2c 20 69 74 | 73 20 74 68 72 65 61 64 |on A, it|s thread|
|000026d0| 73 20 63 61 6e 20 72 75 | 6e 2e 20 54 68 65 20 54 |s can ru|n. The T|
|000026e0| 68 72 65 61 64 20 4d 61 | 6e 61 67 65 72 20 73 61 |hread Ma|nager sa|
|000026f0| 76 65 73 20 74 68 65 20 | 74 68 72 65 61 64 20 63 |ves the |thread c|
|00002700| 6f 6e 74 65 78 74 20 69 | 6e 66 6f 72 6d 61 74 69 |ontext i|nformati|
|00002710| 6f 6e 20 65 61 63 68 20 | 74 69 6d 65 20 69 74 20 |on each |time it |
|00002720| 73 77 69 74 63 68 65 73 | 20 6f 75 74 20 6f 6e 65 |switches| out one|
|00002730| 20 74 68 72 65 61 64 20 | 61 6e 64 20 73 63 68 65 | thread |and sche|
|00002740| 64 75 6c 65 73 20 61 20 | 64 69 66 66 65 72 65 6e |dules a |differen|
|00002750| 74 20 6f 6e 65 20 74 6f | 20 72 75 6e 2e 20 57 68 |t one to| run. Wh|
|00002760| 65 6e 20 74 68 65 20 50 | 72 6f 63 65 73 73 20 4d |en the P|rocess M|
|00002770| 61 6e 61 67 65 72 20 73 | 77 69 74 63 68 65 73 20 |anager s|witches |
|00002780| 69 6e 20 61 70 70 6c 69 | 63 61 74 69 6f 6e 20 42 |in appli|cation B|
|00002790| 2c 20 74 68 65 20 74 68 | 72 65 61 64 73 20 69 6e |, the th|reads in|
|000027a0| 20 61 70 70 6c 69 63 61 | 74 69 6f 6e 20 41 20 61 | applica|tion A a|
|000027b0| 72 65 20 6e 6f 20 6c 6f | 6e 67 65 72 20 61 76 61 |re no lo|nger ava|
|000027c0| 69 6c 61 62 6c 65 20 74 | 6f 20 72 75 6e 20 61 6e |ilable t|o run an|
|000027d0| 64 20 74 68 65 20 54 68 | 72 65 61 64 20 4d 61 6e |d the Th|read Man|
|000027e0| 61 67 65 72 20 6e 6f 77 | 20 6d 61 6e 61 67 65 73 |ager now| manages|
|000027f0| 20 74 68 65 20 74 68 72 | 65 61 64 73 20 69 6e 20 | the thr|eads in |
|00002800| 61 70 70 6c 69 63 61 74 | 69 6f 6e 20 42 2e 0d 0d |applicat|ion B...|
|00002810| 53 63 68 65 64 75 6c 69 | 6e 67 0d 0d 54 68 65 20 |Scheduli|ng..The |
|00002820| 54 68 72 65 61 64 20 4d | 61 6e 61 67 65 72 20 70 |Thread M|anager p|
|00002830| 72 6f 76 69 64 65 73 20 | 61 20 73 69 6e 67 6c 65 |rovides |a single|
|00002840| 2c 20 63 6f 6f 70 65 72 | 61 74 69 76 65 20 6d 65 |, cooper|ative me|
|00002850| 74 68 6f 64 20 6f 66 20 | 73 63 68 65 64 75 6c 69 |thod of |scheduli|
|00002860| 6e 67 20 74 68 72 65 61 | 64 73 2e 20 49 6e 20 63 |ng threa|ds. In c|
|00002870| 6f 6f 70 65 72 61 74 69 | 76 65 20 73 63 68 65 64 |ooperati|ve sched|
|00002880| 75 6c 69 6e 67 2c 20 61 | 20 74 68 72 65 61 64 20 |uling, a| thread |
|00002890| 6d 75 73 74 20 65 78 70 | 6c 69 63 69 74 6c 79 20 |must exp|licitly |
|000028a0| 79 69 65 6c 64 20 63 6f | 6e 74 72 6f 6c 20 74 6f |yield co|ntrol to|
|000028b0| 20 67 69 76 65 20 6f 74 | 68 65 72 20 74 68 72 65 | give ot|her thre|
|000028c0| 61 64 73 20 61 6e 20 6f | 70 70 6f 72 74 75 6e 69 |ads an o|pportuni|
|000028d0| 74 79 20 74 6f 20 72 75 | 6e 2e 20 0d 50 72 65 76 |ty to ru|n. .Prev|
|000028e0| 69 6f 75 73 6c 79 2c 20 | 74 68 65 20 54 68 72 65 |iously, |the Thre|
|000028f0| 61 64 20 4d 61 6e 61 67 | 65 72 20 73 75 70 70 6f |ad Manag|er suppo|
|00002900| 72 74 65 64 20 70 72 65 | 65 6d 70 74 69 76 65 20 |rted pre|emptive |
|00002910| 73 63 68 65 64 75 6c 69 | 6e 67 20 61 73 20 77 65 |scheduli|ng as we|
|00002920| 6c 6c 20 61 73 20 63 6f | 6f 70 65 72 61 74 69 76 |ll as co|operativ|
|00002930| 65 20 73 63 68 65 64 75 | 6c 69 6e 67 2e 20 48 6f |e schedu|ling. Ho|
|00002940| 77 65 76 65 72 2c 20 74 | 68 65 20 75 73 65 20 6f |wever, t|he use o|
|00002950| 66 20 70 72 65 65 6d 70 | 74 69 76 65 20 73 63 68 |f preemp|tive sch|
|00002960| 65 64 75 6c 69 6e 67 20 | 68 61 73 20 61 6c 77 61 |eduling |has alwa|
|00002970| 79 73 20 62 65 65 6e 20 | 73 65 76 65 72 65 6c 79 |ys been |severely|
|00002980| 20 6c 69 6d 69 74 65 64 | 20 62 65 63 61 75 73 65 | limited| because|
|00002990| 20 70 72 65 65 6d 70 74 | 69 76 65 20 73 63 68 65 | preempt|ive sche|
|000029a0| 64 75 6c 69 6e 67 20 64 | 6f 65 73 20 6e 6f 74 20 |duling d|oes not |
|000029b0| 77 6f 72 6b 20 77 69 74 | 68 69 6e 20 61 70 70 6c |work wit|hin appl|
|000029c0| 69 63 61 74 69 6f 6e 73 | 20 75 73 69 6e 67 20 74 |ications| using t|
|000029d0| 68 65 20 50 6f 77 65 72 | 50 43 20 69 6e 73 74 72 |he Power|PC instr|
|000029e0| 75 63 74 69 6f 6e 20 73 | 65 74 2e 20 49 6e 20 61 |uction s|et. In a|
|000029f0| 64 64 69 74 69 6f 6e 2c | 20 4f 70 65 6e 44 6f 63 |ddition,| OpenDoc|
|00002a00| 2c 20 43 46 4d 36 38 4b | 2d 52 75 6e 74 69 6d 65 |, CFM68K|-Runtime|
|00002a10| 20 61 70 70 6c 69 63 61 | 74 69 6f 6e 73 2c 20 61 | applica|tions, a|
|00002a20| 6e 64 20 66 75 74 75 72 | 65 20 6f 70 65 72 61 74 |nd futur|e operat|
|00002a30| 69 6e 67 20 73 79 73 74 | 65 6d 73 2c 20 69 6e 63 |ing syst|ems, inc|
|00002a40| 6c 75 64 69 6e 67 20 43 | 6f 70 6c 61 6e 64 2c 20 |luding C|opland, |
|00002a50| 64 6f 20 6e 6f 74 20 73 | 75 70 70 6f 72 74 20 70 |do not s|upport p|
|00002a60| 72 65 65 6d 70 74 69 76 | 65 20 73 63 68 65 64 75 |reemptiv|e schedu|
|00002a70| 6c 69 6e 67 20 77 69 74 | 68 69 6e 20 61 6e 20 61 |ling wit|hin an a|
|00002a80| 70 70 6c 69 63 61 74 69 | 6f 6e 2e 20 42 65 63 61 |pplicati|on. Beca|
|00002a90| 75 73 65 20 6f 66 20 74 | 68 65 73 65 20 6c 69 6d |use of t|hese lim|
|00002aa0| 69 74 61 74 69 6f 6e 73 | 2c 20 74 68 65 20 54 68 |itations|, the Th|
|00002ab0| 72 65 61 64 20 4d 61 6e | 61 67 65 72 20 6e 6f 20 |read Man|ager no |
|00002ac0| 6c 6f 6e 67 65 72 20 73 | 75 70 70 6f 72 74 73 20 |longer s|upports |
|00002ad0| 70 72 65 65 6d 70 74 69 | 76 65 20 73 63 68 65 64 |preempti|ve sched|
|00002ae0| 75 6c 69 6e 67 2e 20 0d | 49 4d 50 4f 52 54 41 4e |uling. .|IMPORTAN|
|00002af0| 54 0d 49 66 20 79 6f 75 | 20 63 75 72 72 65 6e 74 |T.If you| current|
|00002b00| 6c 79 20 68 61 76 65 20 | 70 72 65 65 6d 70 74 69 |ly have |preempti|
|00002b10| 76 65 20 74 68 72 65 61 | 64 73 20 69 6e 20 79 6f |ve threa|ds in yo|
|00002b20| 75 72 20 61 70 70 6c 69 | 63 61 74 69 6f 6e 2c 20 |ur appli|cation, |
|00002b30| 79 6f 75 20 63 61 6e 20 | 65 61 73 69 6c 79 20 63 |you can |easily c|
|00002b40| 6f 6e 76 65 72 74 20 74 | 68 65 6d 20 74 6f 20 63 |onvert t|hem to c|
|00002b50| 6f 6f 70 65 72 61 74 69 | 76 65 20 74 68 72 65 61 |ooperati|ve threa|
|00002b60| 64 73 20 62 79 20 70 75 | 74 74 69 6e 67 20 6f 6e |ds by pu|tting on|
|00002b70| 65 20 6f 72 20 6d 6f 72 | 65 20 79 69 65 6c 64 20 |e or mor|e yield |
|00002b80| 63 61 6c 6c 73 20 77 69 | 74 68 69 6e 20 74 68 65 |calls wi|thin the|
|00002b90| 20 63 6f 64 65 20 66 6f | 72 20 65 61 63 68 20 74 | code fo|r each t|
|00002ba0| 68 72 65 61 64 2e 20 46 | 6f 72 20 6d 6f 72 65 20 |hread. F|or more |
|00002bb0| 69 6e 66 6f 72 6d 61 74 | 69 6f 6e 2c 20 73 65 65 |informat|ion, see|
|00002bc0| 20 d2 43 6f 6e 76 65 72 | 74 69 6e 67 20 50 72 65 | .Conver|ting Pre|
|00002bd0| 65 6d 70 74 69 76 65 20 | 54 68 72 65 61 64 73 20 |emptive |Threads |
|00002be0| 74 6f 20 43 6f 6f 70 65 | 72 61 74 69 76 65 20 54 |to Coope|rative T|
|00002bf0| 68 72 65 61 64 73 d3 20 | 6f 6e 20 70 61 67 65 20 |hreads. |on page |
|00002c00| 31 2d 33 34 2e 13 73 0d | 0d 54 68 65 20 73 69 74 |1-34..s.|.The sit|
|00002c10| 75 61 74 69 6f 6e 20 66 | 6f 72 20 74 68 72 65 61 |uation f|or threa|
|00002c20| 64 73 20 77 69 74 68 69 | 6e 20 61 6e 20 61 70 70 |ds withi|n an app|
|00002c30| 6c 69 63 61 74 69 6f 6e | 20 69 73 20 73 69 6d 69 |lication| is simi|
|00002c40| 6c 61 72 20 74 6f 20 74 | 68 61 74 20 6f 66 20 61 |lar to t|hat of a|
|00002c50| 70 70 6c 69 63 61 74 69 | 6f 6e 73 20 69 6e 20 61 |pplicati|ons in a|
|00002c60| 20 6d 75 6c 74 69 74 61 | 73 6b 69 6e 67 20 65 6e | multita|sking en|
|00002c70| 76 69 72 6f 6e 6d 65 6e | 74 2e 20 45 76 65 72 79 |vironmen|t. Every|
|00002c80| 20 61 70 70 6c 69 63 61 | 74 69 6f 6e 20 6d 75 73 | applica|tion mus|
|00002c90| 74 20 68 61 76 65 20 70 | 65 72 69 6f 64 69 63 20 |t have p|eriodic |
|00002ca0| 79 69 65 6c 64 69 6e 67 | 20 63 61 6c 6c 73 20 74 |yielding| calls t|
|00002cb0| 68 61 74 20 61 6c 6c 6f | 77 20 74 68 65 20 50 72 |hat allo|w the Pr|
|00002cc0| 6f 63 65 73 73 20 4d 61 | 6e 61 67 65 72 20 74 6f |ocess Ma|nager to|
|00002cd0| 20 73 63 68 65 64 75 6c | 65 20 6f 74 68 65 72 20 | schedul|e other |
|00002ce0| 61 70 70 6c 69 63 61 74 | 69 6f 6e 73 20 61 73 20 |applicat|ions as |
|00002cf0| 6e 65 63 65 73 73 61 72 | 79 d1 66 6f 72 20 65 78 |necessar|y.for ex|
|00002d00| 61 6d 70 6c 65 2c 20 77 | 68 65 6e 20 61 20 75 73 |ample, w|hen a us|
|00002d10| 65 72 20 70 72 65 73 73 | 65 73 20 74 68 65 20 6d |er press|es the m|
|00002d20| 6f 75 73 65 20 62 75 74 | 74 6f 6e 20 74 6f 20 73 |ouse but|ton to s|
|00002d30| 65 6c 65 63 74 20 61 6e | 6f 74 68 65 72 20 61 70 |elect an|other ap|
|00002d40| 70 6c 69 63 61 74 69 6f | 6e 20 74 6f 20 72 75 6e |plicatio|n to run|
|00002d50| 2e 20 4c 69 6b 65 77 69 | 73 65 2c 20 65 76 65 72 |. Likewi|se, ever|
|00002d60| 79 20 74 68 72 65 61 64 | 20 77 69 74 68 69 6e 20 |y thread| within |
|00002d70| 61 6e 20 61 70 70 6c 69 | 63 61 74 69 6f 6e 20 6d |an appli|cation m|
|00002d80| 75 73 74 20 6d 61 6b 65 | 20 72 65 67 75 6c 61 72 |ust make| regular|
|00002d90| 20 79 69 65 6c 64 20 63 | 61 6c 6c 73 20 74 6f 20 | yield c|alls to |
|00002da0| 61 6c 6c 6f 77 20 6f 74 | 68 65 72 20 74 68 72 65 |allow ot|her thre|
|00002db0| 61 64 73 20 74 6f 20 72 | 75 6e 2e 20 54 68 65 20 |ads to r|un. The |
|00002dc0| 54 68 72 65 61 64 20 4d | 61 6e 61 67 65 72 20 70 |Thread M|anager p|
|00002dd0| 72 6f 76 69 64 65 73 20 | 74 68 65 20 66 6f 6c 6c |rovides |the foll|
|00002de0| 6f 77 69 6e 67 20 66 75 | 6e 63 74 69 6f 6e 73 20 |owing fu|nctions |
|00002df0| 74 6f 20 79 69 65 6c 64 | 20 63 6f 6e 74 72 6f 6c |to yield| control|
|00002e00| 20 74 6f 20 6f 74 68 65 | 72 20 74 68 72 65 61 64 | to othe|r thread|
|00002e10| 73 3a 0d 6e 09 59 69 65 | 6c 64 54 6f 41 6e 79 54 |s:.n.Yie|ldToAnyT|
|00002e20| 68 72 65 61 64 2c 20 77 | 68 69 63 68 20 79 69 65 |hread, w|hich yie|
|00002e30| 6c 64 73 20 63 6f 6e 74 | 72 6f 6c 20 74 6f 20 74 |lds cont|rol to t|
|00002e40| 68 65 20 6e 65 78 74 20 | 74 68 72 65 61 64 20 61 |he next |thread a|
|00002e50| 76 61 69 6c 61 62 6c 65 | 20 74 6f 20 72 75 6e 0d |vailable| to run.|
|00002e60| 6e 09 59 69 65 6c 64 54 | 6f 54 68 72 65 61 64 2c |n.YieldT|oThread,|
|00002e70| 20 77 68 69 63 68 20 79 | 69 65 6c 64 73 20 63 6f | which y|ields co|
|00002e80| 6e 74 72 6f 6c 20 74 6f | 20 61 20 73 70 65 63 69 |ntrol to| a speci|
|00002e90| 66 69 63 20 74 68 72 65 | 61 64 2e 0d 6e 09 53 65 |fic thre|ad..n.Se|
|00002ea0| 74 54 68 72 65 61 64 53 | 74 61 74 65 2c 20 77 68 |tThreadS|tate, wh|
|00002eb0| 69 63 68 20 79 6f 75 20 | 63 61 6e 20 75 73 65 20 |ich you |can use |
|00002ec0| 74 6f 20 63 68 61 6e 67 | 65 20 74 68 65 20 73 74 |to chang|e the st|
|00002ed0| 61 74 65 20 6f 66 20 74 | 68 65 20 63 75 72 72 65 |ate of t|he curre|
|00002ee0| 6e 74 20 74 68 72 65 61 | 64 20 66 72 6f 6d 20 72 |nt threa|d from r|
|00002ef0| 75 6e 6e 69 6e 67 20 74 | 6f 20 72 65 61 64 79 20 |unning t|o ready |
|00002f00| 6f 72 20 73 74 6f 70 70 | 65 64 2e 20 57 68 65 6e |or stopp|ed. When|
|00002f10| 20 79 6f 75 20 64 6f 20 | 73 6f 2c 20 79 6f 75 20 | you do |so, you |
|00002f20| 65 69 74 68 65 72 20 73 | 70 65 63 69 66 79 20 61 |either s|pecify a|
|00002f30| 20 6e 65 77 20 74 68 72 | 65 61 64 20 74 6f 20 72 | new thr|ead to r|
|00002f40| 75 6e 20 6f 72 20 6c 65 | 74 20 74 68 65 20 54 68 |un or le|t the Th|
|00002f50| 72 65 61 64 20 4d 61 6e | 61 67 65 72 20 73 63 68 |read Man|ager sch|
|00002f60| 65 64 75 6c 65 20 74 68 | 65 20 6e 65 78 74 20 61 |edule th|e next a|
|00002f70| 76 61 69 6c 61 62 6c 65 | 20 74 68 72 65 61 64 2e |vailable| thread.|
|00002f80| 20 0d 41 73 20 79 6f 75 | 20 63 61 6e 20 73 65 65 | .As you| can see|
|00002f90| 20 66 72 6f 6d 20 74 68 | 65 20 74 68 72 65 65 20 | from th|e three |
|00002fa0| 63 61 6c 6c 73 20 74 68 | 61 74 20 79 69 65 6c 64 |calls th|at yield|
|00002fb0| 20 63 6f 6e 74 72 6f 6c | 20 66 72 6f 6d 20 74 68 | control| from th|
|00002fc0| 65 20 63 75 72 72 65 6e | 74 20 74 68 72 65 61 64 |e curren|t thread|
|00002fd0| 2c 20 74 68 65 72 65 20 | 61 72 65 20 74 77 6f 20 |, there |are two |
|00002fe0| 77 61 79 73 20 74 6f 20 | 64 65 74 65 72 6d 69 6e |ways to |determin|
|00002ff0| 65 20 74 68 65 20 6e 65 | 78 74 20 74 68 72 65 61 |e the ne|xt threa|
|00003000| 64 20 74 6f 20 72 75 6e | 2e 20 4f 6e 65 20 77 61 |d to run|. One wa|
|00003010| 79 20 69 73 20 66 6f 72 | 20 79 6f 75 20 74 6f 20 |y is for| you to |
|00003020| 73 70 65 63 69 66 79 20 | 61 20 70 61 72 74 69 63 |specify |a partic|
|00003030| 75 6c 61 72 20 74 68 72 | 65 61 64 20 74 6f 20 72 |ular thr|ead to r|
|00003040| 75 6e 20 6e 65 78 74 3b | 20 74 68 65 20 6f 74 68 |un next;| the oth|
|00003050| 65 72 20 77 61 79 20 69 | 73 20 74 6f 20 61 6c 6c |er way i|s to all|
|00003060| 6f 77 20 74 68 65 20 54 | 68 72 65 61 64 20 4d 61 |ow the T|hread Ma|
|00003070| 6e 61 67 65 72 20 74 6f | 20 63 68 6f 6f 73 65 20 |nager to| choose |
|00003080| 74 68 65 20 6e 65 78 74 | 20 61 76 61 69 6c 61 62 |the next| availab|
|00003090| 6c 65 20 74 68 72 65 61 | 64 20 74 6f 20 72 75 6e |le threa|d to run|
|000030a0| 2e 20 28 41 6e 20 61 76 | 61 69 6c 61 62 6c 65 20 |. (An av|ailable |
|000030b0| 74 68 72 65 61 64 20 69 | 73 20 6f 6e 65 20 74 68 |thread i|s one th|
|000030c0| 61 74 20 69 73 20 6d 61 | 72 6b 65 64 20 72 65 61 |at is ma|rked rea|
|000030d0| 64 79 20 74 6f 20 72 75 | 6e d1 61 6e 20 75 6e 61 |dy to ru|n.an una|
|000030e0| 76 61 69 6c 61 62 6c 65 | 20 74 68 72 65 61 64 20 |vailable| thread |
|000030f0| 69 73 20 6f 6e 65 20 74 | 68 61 74 20 69 73 20 6d |is one t|hat is m|
|00003100| 61 72 6b 65 64 20 73 74 | 6f 70 70 65 64 2e 29 20 |arked st|opped.) |
|00003110| 54 68 65 20 54 68 72 65 | 61 64 20 4d 61 6e 61 67 |The Thre|ad Manag|
|00003120| 65 72 20 71 75 65 75 65 | 73 20 75 70 20 61 6c 6c |er queue|s up all|
|00003130| 20 6f 66 20 74 68 65 20 | 74 68 72 65 61 64 73 20 | of the |threads |
|00003140| 74 68 61 74 20 61 72 65 | 20 72 65 61 64 79 20 74 |that are| ready t|
|00003150| 6f 20 72 75 6e 2c 20 61 | 6e 64 2c 20 77 68 65 6e |o run, a|nd, when|
|00003160| 20 61 20 6e 6f 6e 73 70 | 65 63 69 66 69 63 20 79 | a nonsp|ecific y|
|00003170| 69 65 6c 64 20 6f 63 63 | 75 72 73 2c 20 69 74 20 |ield occ|urs, it |
|00003180| 65 78 65 63 75 74 65 73 | 20 74 68 65 20 6e 65 78 |executes| the nex|
|00003190| 74 20 61 76 61 69 6c 61 | 62 6c 65 20 74 68 72 65 |t availa|ble thre|
|000031a0| 61 64 2e 20 57 68 65 6e | 20 61 20 74 68 72 65 61 |ad. When| a threa|
|000031b0| 64 20 66 69 6e 69 73 68 | 65 73 20 65 78 65 63 75 |d finish|es execu|
|000031c0| 74 69 6e 67 2c 20 69 74 | 20 6d 6f 76 65 73 20 74 |ting, it| moves t|
|000031d0| 6f 20 74 68 65 20 62 61 | 63 6b 20 6f 66 20 74 68 |o the ba|ck of th|
|000031e0| 65 20 71 75 65 75 65 20 | 69 66 20 69 74 20 69 73 |e queue |if it is|
|000031f0| 20 73 74 69 6c 6c 20 72 | 65 61 64 79 20 74 6f 20 | still r|eady to |
|00003200| 72 75 6e 2c 20 6f 72 2c | 20 69 66 20 69 74 20 69 |run, or,| if it i|
|00003210| 73 20 6d 61 72 6b 65 64 | 20 61 73 20 73 74 6f 70 |s marked| as stop|
|00003220| 70 65 64 2c 20 74 68 65 | 20 54 68 72 65 61 64 20 |ped, the| Thread |
|00003230| 4d 61 6e 61 67 65 72 20 | 72 65 6d 6f 76 65 73 20 |Manager |removes |
|00003240| 69 74 20 66 72 6f 6d 20 | 74 68 65 20 71 75 65 75 |it from |the queu|
|00003250| 65 20 6f 66 20 61 76 61 | 69 6c 61 62 6c 65 20 74 |e of ava|ilable t|
|00003260| 68 72 65 61 64 73 2e 20 | 0d 4e 6f 74 65 0d 54 68 |hreads. |.Note.Th|
|00003270| 65 20 70 72 65 76 69 6f | 75 73 20 70 61 72 61 67 |e previo|us parag|
|00003280| 72 61 70 68 20 64 65 73 | 63 72 69 62 65 73 20 74 |raph des|cribes t|
|00003290| 68 65 20 64 65 66 61 75 | 6c 74 20 54 68 72 65 61 |he defau|lt Threa|
|000032a0| 64 20 4d 61 6e 61 67 65 | 72 20 73 63 68 65 64 75 |d Manage|r schedu|
|000032b0| 6c 69 6e 67 20 6d 65 63 | 68 61 6e 69 73 6d 2e 20 |ling mec|hanism. |
|000032c0| 59 6f 75 20 63 61 6e 20 | 61 6c 73 6f 20 64 65 66 |You can |also def|
|000032d0| 69 6e 65 20 61 20 63 75 | 73 74 6f 6d 20 73 63 68 |ine a cu|stom sch|
|000032e0| 65 64 75 6c 65 72 20 66 | 6f 72 20 79 6f 75 72 20 |eduler f|or your |
|000032f0| 61 70 70 6c 69 63 61 74 | 69 6f 6e 20 74 68 61 74 |applicat|ion that|
|00003300| 20 77 6f 72 6b 73 20 69 | 6e 20 63 6f 6e 6a 75 6e | works i|n conjun|
|00003310| 63 74 69 6f 6e 20 77 69 | 74 68 20 74 68 65 20 64 |ction wi|th the d|
|00003320| 65 66 61 75 6c 74 20 73 | 63 68 65 64 75 6c 69 6e |efault s|chedulin|
|00003330| 67 20 6d 65 63 68 61 6e | 69 73 6d 20 74 6f 20 64 |g mechan|ism to d|
|00003340| 65 74 65 72 6d 69 6e 65 | 20 74 68 65 20 6e 65 78 |etermine| the nex|
|00003350| 74 20 74 68 72 65 61 64 | 20 74 6f 20 72 75 6e 2e |t thread| to run.|
|00003360| 20 53 65 65 20 d2 43 75 | 73 74 6f 6d 20 53 63 68 | See .Cu|stom Sch|
|00003370| 65 64 75 6c 65 72 d3 20 | 6f 6e 20 70 61 67 65 20 |eduler. |on page |
|00003380| 31 2d 38 20 66 6f 72 20 | 6d 6f 72 65 20 69 6e 66 |1-8 for |more inf|
|00003390| 6f 72 6d 61 74 69 6f 6e | 20 61 62 6f 75 74 20 63 |ormation| about c|
|000033a0| 72 65 61 74 69 6e 67 20 | 61 20 63 75 73 74 6f 6d |reating |a custom|
|000033b0| 20 73 63 68 65 64 75 6c | 65 72 20 66 6f 72 20 79 | schedul|er for y|
|000033c0| 6f 75 72 20 61 70 70 6c | 69 63 61 74 69 6f 6e 2e |our appl|ication.|
|000033d0| 20 0d 0d 46 69 67 75 72 | 65 20 31 2d 32 20 73 68 | ..Figur|e 1-2 sh|
|000033e0| 6f 77 73 20 74 68 65 20 | 64 65 66 61 75 6c 74 20 |ows the |default |
|000033f0| 54 68 72 65 61 64 20 4d | 61 6e 61 67 65 72 20 73 |Thread M|anager s|
|00003400| 63 68 65 64 75 6c 69 6e | 67 20 6d 6f 64 65 6c 2e |chedulin|g model.|
|00003410| 20 0d 0d 46 69 67 75 72 | 65 20 31 2d 32 09 0d 54 | ..Figur|e 1-2..T|
|00003420| 68 72 65 61 64 20 73 63 | 68 65 64 75 6c 69 6e 67 |hread sc|heduling|
|00003430| 20 6d 6f 64 65 6c 0d 0d | 42 65 63 61 75 73 65 20 | model..|Because |
|00003440| 74 68 72 65 61 64 73 20 | 79 69 65 6c 64 20 63 6f |threads |yield co|
|00003450| 6e 74 72 6f 6c 20 75 6e | 64 65 72 20 65 78 70 6c |ntrol un|der expl|
|00003460| 69 63 69 74 20 63 6f 6e | 64 69 74 69 6f 6e 73 2c |icit con|ditions,|
|00003470| 20 74 68 65 79 20 68 61 | 76 65 20 61 63 63 65 73 | they ha|ve acces|
|00003480| 73 20 74 6f 20 61 6c 6c | 20 54 6f 6f 6c 62 6f 78 |s to all| Toolbox|
|00003490| 20 61 6e 64 20 4f 70 65 | 72 61 74 69 6e 67 20 53 | and Ope|rating S|
|000034a0| 79 73 74 65 6d 20 72 6f | 75 74 69 6e 65 73 2e 20 |ystem ro|utines. |
|000034b0| 54 68 65 79 20 61 6c 6c | 6f 77 20 79 6f 75 20 64 |They all|ow you d|
|000034c0| 6f 20 61 6e 79 74 68 69 | 6e 67 20 74 68 61 74 20 |o anythi|ng that |
|000034d0| 79 6f 75 20 63 61 6e 20 | 63 75 72 72 65 6e 74 6c |you can |currentl|
|000034e0| 79 20 64 6f 20 69 6e 20 | 61 6e 20 61 70 70 6c 69 |y do in |an appli|
|000034f0| 63 61 74 69 6f 6e 20 77 | 69 74 68 6f 75 74 20 74 |cation w|ithout t|
|00003500| 68 72 65 61 64 73 2c 20 | 73 75 63 68 20 61 73 20 |hreads, |such as |
|00003510| 61 6c 6c 6f 63 61 74 65 | 20 6d 65 6d 6f 72 79 2c |allocate| memory,|
|00003520| 20 70 65 72 66 6f 72 6d | 20 66 69 6c 65 20 49 2f | perform| file I/|
|00003530| 4f 2c 20 70 65 72 66 6f | 72 6d 20 51 75 69 63 6b |O, perfo|rm Quick|
|00003540| 44 72 61 77 20 6f 70 65 | 72 61 74 69 6f 6e 73 2c |Draw ope|rations,|
|00003550| 20 61 6e 64 20 73 6f 20 | 6f 6e 2e 20 0d 46 6f 72 | and so |on. .For|
|00003560| 20 73 69 74 75 61 74 69 | 6f 6e 73 20 69 6e 20 77 | situati|ons in w|
|00003570| 68 69 63 68 20 79 6f 75 | 20 61 72 65 20 63 6f 6e |hich you| are con|
|00003580| 63 65 72 6e 65 64 20 61 | 62 6f 75 74 20 74 68 65 |cerned a|bout the|
|00003590| 20 69 6e 74 65 67 72 69 | 74 79 20 6f 66 20 79 6f | integri|ty of yo|
|000035a0| 75 72 20 64 61 74 61 2c | 20 74 68 65 20 54 68 72 |ur data,| the Thr|
|000035b0| 65 61 64 20 4d 61 6e 61 | 67 65 72 20 70 72 6f 76 |ead Mana|ger prov|
|000035c0| 69 64 65 73 20 61 20 70 | 61 69 72 20 6f 66 20 66 |ides a p|air of f|
|000035d0| 75 6e 63 74 69 6f 6e 73 | 2c 20 54 68 72 65 61 64 |unctions|, Thread|
|000035e0| 42 65 67 69 6e 43 72 69 | 74 69 63 61 6c 20 61 6e |BeginCri|tical an|
|000035f0| 64 20 54 68 72 65 61 64 | 45 6e 64 43 72 69 74 69 |d Thread|EndCriti|
|00003600| 63 61 6c 2c 20 74 68 61 | 74 20 65 6e 61 62 6c 65 |cal, tha|t enable|
|00003610| 20 79 6f 75 20 74 6f 20 | 6d 61 72 6b 20 61 20 73 | you to |mark a s|
|00003620| 65 63 74 69 6f 6e 20 6f | 66 20 63 6f 64 65 20 61 |ection o|f code a|
|00003630| 73 20 63 72 69 74 69 63 | 61 6c 2c 20 74 75 72 6e |s critic|al, turn|
|00003640| 69 6e 67 20 73 63 68 65 | 64 75 6c 69 6e 67 20 6f |ing sche|duling o|
|00003650| 66 66 2e 20 57 69 74 68 | 20 73 63 68 65 64 75 6c |ff. With| schedul|
|00003660| 69 6e 67 20 6f 66 66 2c | 20 74 68 65 20 54 68 72 |ing off,| the Thr|
|00003670| 65 61 64 20 4d 61 6e 61 | 67 65 72 20 64 6f 65 73 |ead Mana|ger does|
|00003680| 20 6e 6f 74 20 61 6c 6c | 6f 77 20 61 6e 79 20 74 | not all|ow any t|
|00003690| 68 72 65 61 64 73 20 74 | 6f 20 62 65 20 73 63 68 |hreads t|o be sch|
|000036a0| 65 64 75 6c 65 64 20 75 | 6e 74 69 6c 20 73 63 68 |eduled u|ntil sch|
|000036b0| 65 64 75 6c 69 6e 67 20 | 69 73 20 74 75 72 6e 65 |eduling |is turne|
|000036c0| 64 20 62 61 63 6b 20 6f | 6e 3b 20 74 68 61 74 20 |d back o|n; that |
|000036d0| 69 73 2c 20 61 6c 6c 20 | 79 69 65 6c 64 20 61 6e |is, all |yield an|
|000036e0| 64 20 6f 74 68 65 72 20 | 73 63 68 65 64 75 6c 69 |d other |scheduli|
|000036f0| 6e 67 20 66 75 6e 63 74 | 69 6f 6e 73 20 61 72 65 |ng funct|ions are|
|00003700| 20 69 67 6e 6f 72 65 64 | 20 75 6e 74 69 6c 20 74 | ignored| until t|
|00003710| 68 65 20 63 6f 64 65 20 | 65 78 69 74 73 20 74 68 |he code |exits th|
|00003720| 65 20 63 72 69 74 69 63 | 61 6c 20 73 65 63 74 69 |e critic|al secti|
|00003730| 6f 6e 2e 20 53 65 65 20 | d2 54 75 72 6e 69 6e 67 |on. See |.Turning|
|00003740| 20 53 63 68 65 64 75 6c | 69 6e 67 20 4f 66 66 d3 | Schedul|ing Off.|
|00003750| 20 62 65 67 69 6e 6e 69 | 6e 67 20 6f 6e 20 70 61 | beginni|ng on pa|
|00003760| 67 65 20 31 2d 32 30 20 | 66 6f 72 20 69 6e 66 6f |ge 1-20 |for info|
|00003770| 72 6d 61 74 69 6f 6e 20 | 6f 6e 20 68 6f 77 20 61 |rmation |on how a|
|00003780| 6e 64 20 77 68 65 6e 20 | 74 6f 20 6d 61 72 6b 20 |nd when |to mark |
|00003790| 73 65 63 74 69 6f 6e 73 | 20 6f 66 20 63 6f 64 65 |sections| of code|
|000037a0| 20 61 73 20 63 72 69 74 | 69 63 61 6c 2e 0d 0d 54 | as crit|ical...T|
|000037b0| 68 65 20 4d 61 69 6e 20 | 54 68 72 65 61 64 20 0d |he Main |Thread .|
|000037c0| 0d 57 68 65 6e 20 74 68 | 65 20 50 72 6f 63 65 73 |.When th|e Proces|
|000037d0| 73 20 4d 61 6e 61 67 65 | 72 20 6c 61 75 6e 63 68 |s Manage|r launch|
|000037e0| 65 73 20 79 6f 75 72 20 | 61 70 70 6c 69 63 61 74 |es your |applicat|
|000037f0| 69 6f 6e 2c 20 69 74 20 | 63 72 65 61 74 65 73 20 |ion, it |creates |
|00003800| 61 6e 64 20 72 75 6e 73 | 20 61 20 73 70 65 63 69 |and runs| a speci|
|00003810| 61 6c 20 74 68 72 65 61 | 64 2c 20 63 61 6c 6c 65 |al threa|d, calle|
|00003820| 64 20 74 68 65 20 6d 61 | 69 6e 20 74 68 72 65 61 |d the ma|in threa|
|00003830| 64 20 6f 72 20 61 70 70 | 6c 69 63 61 74 69 6f 6e |d or app|lication|
|00003840| 20 74 68 72 65 61 64 2e | 20 54 68 65 20 6d 61 69 | thread.| The mai|
|00003850| 6e 20 66 75 6e 63 74 69 | 6f 6e 20 69 73 20 74 68 |n functi|on is th|
|00003860| 65 20 65 6e 74 72 79 20 | 70 6f 69 6e 74 20 74 6f |e entry |point to|
|00003870| 20 74 68 69 73 20 74 68 | 72 65 61 64 20 61 6e 64 | this th|read and|
|00003880| 20 74 6f 20 74 68 65 20 | 61 70 70 6c 69 63 61 74 | to the |applicat|
|00003890| 69 6f 6e 2e 20 54 68 65 | 20 6d 61 69 6e 20 74 68 |ion. The| main th|
|000038a0| 72 65 61 64 20 68 61 73 | 20 73 6f 6d 65 20 63 68 |read has| some ch|
|000038b0| 61 72 61 63 74 65 72 69 | 73 74 69 63 73 20 74 68 |aracteri|stics th|
|000038c0| 61 74 20 64 69 73 74 69 | 6e 67 75 69 73 68 20 69 |at disti|nguish i|
|000038d0| 74 20 66 72 6f 6d 20 6f | 74 68 65 72 20 74 68 72 |t from o|ther thr|
|000038e0| 65 61 64 73 2e 20 49 74 | 20 69 73 20 74 68 65 20 |eads. It| is the |
|000038f0| 6f 6e 6c 79 20 74 68 72 | 65 61 64 20 74 68 61 74 |only thr|ead that|
|00003900| 20 68 61 73 20 61 20 70 | 72 65 61 6c 6c 6f 63 61 | has a p|realloca|
|00003910| 74 65 64 20 73 74 61 63 | 6b d1 74 68 65 20 73 74 |ted stac|k.the st|
|00003920| 61 63 6b 73 20 66 6f 72 | 20 74 68 72 65 61 64 73 |acks for| threads|
|00003930| 20 74 68 61 74 20 79 6f | 75 72 20 61 70 70 6c 69 | that yo|ur appli|
|00003940| 63 61 74 69 6f 6e 20 63 | 72 65 61 74 65 73 20 72 |cation c|reates r|
|00003950| 65 73 69 64 65 20 69 6e | 20 73 65 70 61 72 61 74 |eside in| separat|
|00003960| 65 20 61 72 65 61 73 20 | 6f 66 20 74 68 65 20 68 |e areas |of the h|
|00003970| 65 61 70 2e 20 54 68 65 | 20 6d 61 69 6e 20 74 68 |eap. The| main th|
|00003980| 72 65 61 64 20 69 73 20 | 74 68 65 20 6f 6e 6c 79 |read is |the only|
|00003990| 20 74 68 72 65 61 64 20 | 66 72 6f 6d 20 77 68 69 | thread |from whi|
|000039a0| 63 68 20 79 6f 75 20 70 | 72 6f 70 65 72 6c 79 20 |ch you p|roperly |
|000039b0| 63 61 6e 20 65 78 74 65 | 6e 64 20 74 68 65 20 61 |can exte|nd the a|
|000039c0| 70 70 6c 69 63 61 74 69 | 6f 6e 20 68 65 61 70 2e |pplicati|on heap.|
|000039d0| 20 54 68 65 72 65 66 6f | 72 65 20 79 6f 75 20 73 | Therefo|re you s|
|000039e0| 68 6f 75 6c 64 20 63 61 | 6c 6c 20 4d 61 78 41 70 |hould ca|ll MaxAp|
|000039f0| 70 6c 5a 6f 6e 65 20 66 | 72 6f 6d 20 74 68 65 20 |plZone f|rom the |
|00003a00| 6d 61 69 6e 20 74 68 72 | 65 61 64 20 69 6d 6d 65 |main thr|ead imme|
|00003a10| 64 69 61 74 65 6c 79 20 | 61 66 74 65 72 20 79 6f |diately |after yo|
|00003a20| 75 72 20 61 70 70 6c 69 | 63 61 74 69 6f 6e 20 6c |ur appli|cation l|
|00003a30| 61 75 6e 63 68 65 73 2c | 20 6f 72 20 61 74 20 6c |aunches,| or at l|
|00003a40| 65 61 73 74 20 62 65 66 | 6f 72 65 20 61 6e 79 20 |east bef|ore any |
|00003a50| 6f 74 68 65 72 20 74 68 | 72 65 61 64 73 20 72 75 |other th|reads ru|
|00003a60| 6e 2e 0d 41 6e 6f 74 68 | 65 72 20 63 68 61 72 61 |n..Anoth|er chara|
|00003a70| 63 74 65 72 69 73 74 69 | 63 20 6f 66 20 74 68 65 |cteristi|c of the|
|00003a80| 20 6d 61 69 6e 20 74 68 | 72 65 61 64 20 69 73 20 | main th|read is |
|00003a90| 74 68 61 74 20 74 68 65 | 20 54 68 72 65 61 64 20 |that the| Thread |
|00003aa0| 4d 61 6e 61 67 65 72 20 | 61 73 73 75 6d 65 73 20 |Manager |assumes |
|00003ab0| 74 68 65 20 6d 61 69 6e | 20 74 68 72 65 61 64 20 |the main| thread |
|00003ac0| 68 61 6e 64 6c 65 73 20 | 65 76 65 6e 74 20 70 72 |handles |event pr|
|00003ad0| 6f 63 65 73 73 69 6e 67 | 2e 20 54 68 65 72 65 66 |ocessing|. Theref|
|00003ae0| 6f 72 65 2c 20 77 68 65 | 6e 65 76 65 72 20 61 6e |ore, whe|never an|
|00003af0| 20 6f 70 65 72 61 74 69 | 6e 67 2d 73 79 73 74 65 | operati|ng-syste|
|00003b00| 6d 20 65 76 65 6e 74 20 | 6f 63 63 75 72 73 2c 20 |m event |occurs, |
|00003b10| 74 68 65 20 54 68 72 65 | 61 64 20 4d 61 6e 61 67 |the Thre|ad Manag|
|00003b20| 65 72 20 73 63 68 65 64 | 75 6c 65 73 20 74 68 65 |er sched|ules the|
|00003b30| 20 6d 61 69 6e 20 74 68 | 72 65 61 64 20 61 74 20 | main th|read at |
|00003b40| 74 68 65 20 6e 65 78 74 | 20 73 63 68 65 64 75 6c |the next| schedul|
|00003b50| 69 6e 67 20 6f 70 70 6f | 72 74 75 6e 69 74 79 2c |ing oppo|rtunity,|
|00003b60| 20 6e 6f 20 6d 61 74 74 | 65 72 20 77 68 65 72 65 | no matt|er where|
|00003b70| 20 74 68 65 20 6d 61 69 | 6e 20 74 68 72 65 61 64 | the mai|n thread|
|00003b80| 20 68 61 70 70 65 6e 73 | 20 74 6f 20 62 65 20 69 | happens| to be i|
|00003b90| 6e 20 74 68 65 20 73 63 | 68 65 64 75 6c 69 6e 67 |n the sc|heduling|
|00003ba0| 20 71 75 65 75 65 2e 20 | 0d 4e 6f 74 65 0d 41 66 | queue. |.Note.Af|
|00003bb0| 74 65 72 20 61 6e 20 6f | 70 65 72 61 74 69 6e 67 |ter an o|perating|
|00003bc0| 2d 73 79 73 74 65 6d 20 | 65 76 65 6e 74 2c 20 74 |-system |event, t|
|00003bd0| 68 65 20 54 68 72 65 61 | 64 20 4d 61 6e 61 67 65 |he Threa|d Manage|
|00003be0| 72 20 73 63 68 65 64 75 | 6c 65 73 20 74 68 65 20 |r schedu|les the |
|00003bf0| 6d 61 69 6e 20 74 68 72 | 65 61 64 20 61 74 20 74 |main thr|ead at t|
|00003c00| 68 65 20 6e 65 78 74 20 | 6f 70 70 6f 72 74 75 6e |he next |opportun|
|00003c10| 69 74 79 20 75 6e 6c 65 | 73 73 20 79 6f 75 20 68 |ity unle|ss you h|
|00003c20| 61 76 65 20 73 70 65 63 | 69 66 69 65 64 20 61 20 |ave spec|ified a |
|00003c30| 70 61 72 74 69 63 75 6c | 61 72 20 74 68 72 65 61 |particul|ar threa|
|00003c40| 64 20 74 6f 20 72 75 6e | 2e 20 49 6e 20 6f 74 68 |d to run|. In oth|
|00003c50| 65 72 20 77 6f 72 64 73 | 2c 20 69 66 20 79 6f 75 |er words|, if you|
|00003c60| 20 63 61 6c 6c 20 61 20 | 66 75 6e 63 74 69 6f 6e | call a |function|
|00003c70| 20 73 75 63 68 20 61 73 | 20 59 69 65 6c 64 54 6f | such as| YieldTo|
|00003c80| 41 6e 79 54 68 72 65 61 | 64 20 74 6f 20 63 61 75 |AnyThrea|d to cau|
|00003c90| 73 65 20 74 68 65 20 72 | 65 73 63 68 65 64 75 6c |se the r|eschedul|
|00003ca0| 69 6e 67 2c 20 74 68 65 | 20 54 68 72 65 61 64 20 |ing, the| Thread |
|00003cb0| 4d 61 6e 61 67 65 72 20 | 72 75 6e 73 20 74 68 65 |Manager |runs the|
|00003cc0| 20 6d 61 69 6e 20 74 68 | 72 65 61 64 2e 20 49 66 | main th|read. If|
|00003cd0| 2c 20 68 6f 77 65 76 65 | 72 2c 20 79 6f 75 20 63 |, howeve|r, you c|
|00003ce0| 61 6c 6c 20 61 20 66 75 | 6e 63 74 69 6f 6e 20 73 |all a fu|nction s|
|00003cf0| 75 63 68 20 61 73 20 59 | 69 65 6c 64 54 6f 54 68 |uch as Y|ieldToTh|
|00003d00| 72 65 61 64 20 61 6e 64 | 20 73 70 65 63 69 66 79 |read and| specify|
|00003d10| 20 61 20 70 61 72 74 69 | 63 75 6c 61 72 20 74 68 | a parti|cular th|
|00003d20| 72 65 61 64 20 74 6f 20 | 72 75 6e 2c 20 74 68 65 |read to |run, the|
|00003d30| 20 54 68 72 65 61 64 20 | 4d 61 6e 61 67 65 72 20 | Thread |Manager |
|00003d40| 73 63 68 65 64 75 6c 65 | 73 20 74 68 61 74 20 74 |schedule|s that t|
|00003d50| 68 72 65 61 64 20 72 61 | 74 68 65 72 20 74 68 61 |hread ra|ther tha|
|00003d60| 6e 20 74 68 65 20 6d 61 | 69 6e 20 74 68 72 65 61 |n the ma|in threa|
|00003d70| 64 20 65 76 65 6e 20 61 | 66 74 65 72 20 74 68 65 |d even a|fter the|
|00003d80| 20 6f 63 63 75 72 72 65 | 6e 63 65 20 6f 66 20 61 | occurre|nce of a|
|00003d90| 6e 20 6f 70 65 72 61 74 | 69 6e 67 2d 73 79 73 74 |n operat|ing-syst|
|00003da0| 65 6d 20 65 76 65 6e 74 | 2e 20 13 75 0d 0d 54 6f |em event|. .u..To|
|00003db0| 20 67 75 61 72 61 6e 74 | 65 65 20 72 65 73 70 6f | guarant|ee respo|
|00003dc0| 6e 73 69 76 65 6e 65 73 | 73 20 74 6f 20 75 73 65 |nsivenes|s to use|
|00003dd0| 72 73 2c 20 79 6f 75 20 | 73 68 6f 75 6c 64 20 70 |rs, you |should p|
|00003de0| 75 74 20 61 6c 6c 20 79 | 6f 75 72 20 65 76 65 6e |ut all y|our even|
|00003df0| 74 20 68 61 6e 64 6c 69 | 6e 67 20 69 6e 20 74 68 |t handli|ng in th|
|00003e00| 65 20 6d 61 69 6e 20 74 | 68 72 65 61 64 2e 20 46 |e main t|hread. F|
|00003e10| 6f 72 20 74 68 65 20 73 | 61 6d 65 20 72 65 61 73 |or the s|ame reas|
|00003e20| 6f 6e 2c 20 69 74 20 69 | 73 20 68 69 67 68 6c 79 |on, it i|s highly|
|00003e30| 20 72 65 63 6f 6d 6d 65 | 6e 64 65 64 20 74 68 61 | recomme|nded tha|
|00003e40| 74 20 79 6f 75 20 6e 65 | 76 65 72 20 70 75 74 20 |t you ne|ver put |
|00003e50| 74 68 65 20 6d 61 69 6e | 20 74 68 72 65 61 64 20 |the main| thread |
|00003e60| 69 6e 20 74 68 65 20 73 | 74 6f 70 70 65 64 20 73 |in the s|topped s|
|00003e70| 74 61 74 65 2e 20 0d 0d | 43 75 73 74 6f 6d 20 53 |tate. ..|Custom S|
|00003e80| 63 68 65 64 75 6c 65 72 | 0d 0d 54 68 65 20 54 68 |cheduler|..The Th|
|00003e90| 72 65 61 64 20 4d 61 6e | 61 67 65 72 20 61 6c 6c |read Man|ager all|
|00003ea0| 6f 77 73 20 79 6f 75 20 | 74 6f 20 69 6e 73 74 61 |ows you |to insta|
|00003eb0| 6c 6c 20 61 20 63 75 73 | 74 6f 6d 20 73 63 68 65 |ll a cus|tom sche|
|00003ec0| 64 75 6c 69 6e 67 20 66 | 75 6e 63 74 69 6f 6e 20 |duling f|unction |
|00003ed0| 74 68 61 74 20 77 6f 72 | 6b 73 20 69 6e 20 63 6f |that wor|ks in co|
|00003ee0| 6e 6a 75 6e 63 74 69 6f | 6e 20 77 69 74 68 20 74 |njunctio|n with t|
|00003ef0| 68 65 20 54 68 72 65 61 | 64 20 4d 61 6e 61 67 65 |he Threa|d Manage|
|00003f00| 72 20 64 65 66 61 75 6c | 74 20 73 63 68 65 64 75 |r defaul|t schedu|
|00003f10| 6c 69 6e 67 20 6d 65 63 | 68 61 6e 69 73 6d 2e 20 |ling mec|hanism. |
|00003f20| 59 6f 75 20 69 6e 73 74 | 61 6c 6c 20 74 68 65 20 |You inst|all the |
|00003f30| 63 75 73 74 6f 6d 20 73 | 63 68 65 64 75 6c 69 6e |custom s|chedulin|
|00003f40| 67 20 66 75 6e 63 74 69 | 6f 6e 20 77 69 74 68 20 |g functi|on with |
|00003f50| 74 68 65 20 53 65 74 54 | 68 72 65 61 64 53 63 68 |the SetT|hreadSch|
|00003f60| 65 64 75 6c 65 72 20 66 | 75 6e 63 74 69 6f 6e 2e |eduler f|unction.|
|00003f70| 20 46 69 67 75 72 65 20 | 31 2d 33 20 73 68 6f 77 | Figure |1-3 show|
|00003f80| 73 20 68 6f 77 20 74 68 | 65 20 63 75 73 74 6f 6d |s how th|e custom|
|00003f90| 20 73 63 68 65 64 75 6c | 65 72 20 77 6f 72 6b 73 | schedul|er works|
|00003fa0| 20 77 69 74 68 20 74 68 | 65 20 64 65 66 61 75 6c | with th|e defaul|
|00003fb0| 74 20 54 68 72 65 61 64 | 20 4d 61 6e 61 67 65 72 |t Thread| Manager|
|00003fc0| 20 73 63 68 65 64 75 6c | 69 6e 67 20 6d 65 63 68 | schedul|ing mech|
|00003fd0| 61 6e 69 73 6d 2e 0d 0d | 46 69 67 75 72 65 20 31 |anism...|Figure 1|
|00003fe0| 2d 33 09 0d 54 68 72 65 | 61 64 20 4d 61 6e 61 67 |-3..Thre|ad Manag|
|00003ff0| 65 72 20 64 65 66 61 75 | 6c 74 20 61 6e 64 20 63 |er defau|lt and c|
|00004000| 75 73 74 6f 6d 20 73 63 | 68 65 64 75 6c 69 6e 67 |ustom sc|heduling|
|00004010| 20 6d 65 63 68 61 6e 69 | 73 6d 73 0d 0d 57 68 65 | mechani|sms..Whe|
|00004020| 6e 20 61 20 79 69 65 6c | 64 20 6f 72 20 6f 74 68 |n a yiel|d or oth|
|00004030| 65 72 20 54 68 72 65 61 | 64 20 4d 61 6e 61 67 65 |er Threa|d Manage|
|00004040| 72 20 63 61 6c 6c 20 74 | 72 69 67 67 65 72 73 20 |r call t|riggers |
|00004050| 61 20 72 65 73 63 68 65 | 64 75 6c 65 2c 20 74 68 |a resche|dule, th|
|00004060| 65 20 54 68 72 65 61 64 | 20 4d 61 6e 61 67 65 72 |e Thread| Manager|
|00004070| 20 63 61 6c 6c 73 20 74 | 68 65 20 63 75 73 74 6f | calls t|he custo|
|00004080| 6d 20 73 63 68 65 64 75 | 6c 69 6e 67 20 66 75 6e |m schedu|ling fun|
|00004090| 63 74 69 6f 6e 20 61 6e | 64 20 70 61 73 73 65 73 |ction an|d passes|
|000040a0| 20 69 74 20 61 20 73 63 | 68 65 64 75 6c 65 72 20 | it a sc|heduler |
|000040b0| 69 6e 66 6f 72 6d 61 74 | 69 6f 6e 20 73 74 72 75 |informat|ion stru|
|000040c0| 63 74 75 72 65 2e 20 54 | 68 69 73 20 73 74 72 75 |cture. T|his stru|
|000040d0| 63 74 75 72 65 20 68 61 | 73 20 66 6f 75 72 20 66 |cture ha|s four f|
|000040e0| 69 65 6c 64 73 3b 20 74 | 68 65 20 66 69 72 73 74 |ields; t|he first|
|000040f0| 20 63 6f 6e 74 61 69 6e | 73 20 74 68 65 20 73 69 | contain|s the si|
|00004100| 7a 65 20 6f 66 20 74 68 | 65 20 73 74 72 75 63 74 |ze of th|e struct|
|00004110| 75 72 65 20 61 6e 64 20 | 61 6c 6c 6f 77 73 20 66 |ure and |allows f|
|00004120| 6f 72 20 65 78 70 61 6e | 73 69 6f 6e 20 69 6e 20 |or expan|sion in |
|00004130| 74 68 65 20 66 75 74 75 | 72 65 2e 20 54 68 65 20 |the futu|re. The |
|00004140| 6e 65 78 74 20 74 77 6f | 20 66 69 65 6c 64 73 20 |next two| fields |
|00004150| 61 72 65 20 74 68 72 65 | 61 64 20 49 44 73 20 74 |are thre|ad IDs t|
|00004160| 68 61 74 20 69 64 65 6e | 74 69 66 79 20 74 68 65 |hat iden|tify the|
|00004170| 20 63 75 72 72 65 6e 74 | 20 74 68 72 65 61 64 20 | current| thread |
|00004180| 61 6e 64 20 74 68 65 20 | 74 68 72 65 61 64 20 74 |and the |thread t|
|00004190| 68 61 74 20 74 68 65 20 | 61 70 70 6c 69 63 61 74 |hat the |applicat|
|000041a0| 69 6f 6e 20 68 61 73 20 | 73 65 6c 65 63 74 65 64 |ion has |selected|
|000041b0| 20 74 6f 20 72 75 6e 20 | 6e 65 78 74 2e 20 54 68 | to run |next. Th|
|000041c0| 65 20 66 69 6e 61 6c 20 | 66 69 65 6c 64 20 77 61 |e final |field wa|
|000041d0| 73 20 74 6f 20 69 64 65 | 6e 74 69 66 79 20 61 20 |s to ide|ntify a |
|000041e0| 63 6f 6f 70 65 72 61 74 | 69 76 65 20 74 68 72 65 |cooperat|ive thre|
|000041f0| 61 64 20 74 68 61 74 20 | 77 61 73 20 69 6e 74 65 |ad that |was inte|
|00004200| 72 72 75 70 74 65 64 20 | 62 79 20 61 20 70 72 65 |rrupted |by a pre|
|00004210| 65 6d 70 74 69 76 65 20 | 74 68 72 65 61 64 2e 20 |emptive |thread. |
|00004220| 48 6f 77 65 76 65 72 2c | 20 62 65 63 61 75 73 65 |However,| because|
|00004230| 20 69 74 20 6e 6f 20 6c | 6f 6e 67 65 72 20 73 75 | it no l|onger su|
|00004240| 70 70 6f 72 74 73 20 70 | 72 65 65 6d 70 74 69 76 |pports p|reemptiv|
|00004250| 65 20 74 68 72 65 61 64 | 73 2c 20 74 68 65 20 54 |e thread|s, the T|
|00004260| 68 72 65 61 64 20 4d 61 | 6e 61 67 65 72 20 61 6c |hread Ma|nager al|
|00004270| 77 61 79 73 20 70 61 73 | 73 65 73 20 74 68 65 20 |ways pas|ses the |
|00004280| 6b 4e 6f 54 68 72 65 61 | 64 49 44 20 63 6f 6e 73 |kNoThrea|dID cons|
|00004290| 74 61 6e 74 20 66 6f 72 | 20 74 68 69 73 20 66 69 |tant for| this fi|
|000042a0| 65 6c 64 2e 20 0d 54 68 | 65 20 63 75 73 74 6f 6d |eld. .Th|e custom|
|000042b0| 20 73 63 68 65 64 75 6c | 69 6e 67 20 66 75 6e 63 | schedul|ing func|
|000042c0| 74 69 6f 6e 20 63 61 6e | 20 75 73 65 20 74 68 69 |tion can| use thi|
|000042d0| 73 20 69 6e 66 6f 72 6d | 61 74 69 6f 6e 20 74 6f |s inform|ation to|
|000042e0| 20 64 65 74 65 72 6d 69 | 6e 65 20 77 68 69 63 68 | determi|ne which|
|000042f0| 20 74 68 72 65 61 64 20 | 74 6f 20 73 63 68 65 64 | thread |to sched|
|00004300| 75 6c 65 20 6e 65 78 74 | 2e 20 49 74 20 72 65 74 |ule next|. It ret|
|00004310| 75 72 6e 73 20 74 6f 20 | 74 68 65 20 64 65 66 61 |urns to |the defa|
|00004320| 75 6c 74 20 73 63 68 65 | 64 75 6c 69 6e 67 20 6d |ult sche|duling m|
|00004330| 65 63 68 61 6e 69 73 6d | 20 74 68 65 20 74 68 72 |echanism| the thr|
|00004340| 65 61 64 20 49 44 20 6f | 66 20 74 68 65 20 6e 65 |ead ID o|f the ne|
|00004350| 78 74 20 74 68 72 65 61 | 64 20 74 6f 20 73 63 68 |xt threa|d to sch|
|00004360| 65 64 75 6c 65 20 61 6e | 64 20 74 68 65 20 54 68 |edule an|d the Th|
|00004370| 72 65 61 64 20 4d 61 6e | 61 67 65 72 20 64 6f 65 |read Man|ager doe|
|00004380| 73 20 74 68 65 20 61 63 | 74 75 61 6c 20 73 63 68 |s the ac|tual sch|
|00004390| 65 64 75 6c 69 6e 67 2e | 0d 0d 44 65 66 61 75 6c |eduling.|..Defaul|
|000043a0| 74 20 53 61 76 65 64 20 | 54 68 72 65 61 64 20 43 |t Saved |Thread C|
|000043b0| 6f 6e 74 65 78 74 0d 0d | 57 68 65 6e 20 74 68 65 |ontext..|When the|
|000043c0| 20 54 68 72 65 61 64 20 | 4d 61 6e 61 67 65 72 20 | Thread |Manager |
|000043d0| 73 77 69 74 63 68 65 73 | 20 74 68 65 20 63 6f 6e |switches| the con|
|000043e0| 74 65 78 74 20 62 65 74 | 77 65 65 6e 20 6f 6e 65 |text bet|ween one|
|000043f0| 20 74 68 72 65 61 64 20 | 61 6e 64 20 61 6e 6f 74 | thread |and anot|
|00004400| 68 65 72 2c 20 69 74 20 | 73 61 76 65 73 20 61 20 |her, it |saves a |
|00004410| 64 65 66 61 75 6c 74 20 | 63 6f 6e 74 65 78 74 2c |default |context,|
|00004420| 20 77 68 69 63 68 20 63 | 6f 6e 73 69 73 74 73 20 | which c|onsists |
|00004430| 6f 66 20 74 68 65 20 43 | 50 55 20 72 65 67 69 73 |of the C|PU regis|
|00004440| 74 65 72 73 2c 20 74 68 | 65 20 66 6c 6f 61 74 69 |ters, th|e floati|
|00004450| 6e 67 2d 70 6f 69 6e 74 | 20 28 46 50 55 29 20 72 |ng-point| (FPU) r|
|00004460| 65 67 69 73 74 65 72 73 | 20 28 69 66 20 61 6e 79 |egisters| (if any|
|00004470| 29 2c 20 61 6e 64 20 74 | 68 65 20 6c 6f 63 61 74 |), and t|he locat|
|00004480| 69 6f 6e 20 6f 66 20 74 | 68 65 20 63 6f 6e 74 65 |ion of t|he conte|
|00004490| 78 74 20 69 6e 66 6f 72 | 6d 61 74 69 6f 6e 2e 20 |xt infor|mation. |
|000044a0| 0d 54 68 65 20 74 68 72 | 65 61 64 20 63 6f 6e 74 |.The thr|ead cont|
|000044b0| 65 78 74 20 72 65 73 69 | 64 65 73 20 6f 6e 20 61 |ext resi|des on a|
|000044c0| 20 74 68 72 65 61 64 d5 | 73 20 73 74 61 63 6b 20 | thread.|s stack |
|000044d0| 61 6e 64 20 74 68 65 20 | 54 68 72 65 61 64 20 4d |and the |Thread M|
|000044e0| 61 6e 61 67 65 72 20 73 | 61 76 65 73 20 74 68 65 |anager s|aves the|
|000044f0| 20 6c 6f 63 61 74 69 6f | 6e 20 6f 66 20 74 68 69 | locatio|n of thi|
|00004500| 73 20 63 6f 6e 74 65 78 | 74 20 77 68 65 6e 20 69 |s contex|t when i|
|00004510| 74 20 73 77 69 74 63 68 | 65 73 20 63 6f 6e 74 65 |t switch|es conte|
|00004520| 78 74 73 20 62 65 74 77 | 65 65 6e 20 74 68 72 65 |xts betw|een thre|
|00004530| 61 64 73 2e 20 54 68 65 | 20 41 35 20 72 65 67 69 |ads. The| A5 regi|
|00004540| 73 74 65 72 20 28 47 50 | 52 31 20 6f 6e 20 74 68 |ster (GP|R1 on th|
|00004550| 65 20 50 6f 77 65 72 50 | 43 29 20 66 6f 72 20 65 |e PowerP|C) for e|
|00004560| 61 63 68 20 74 68 72 65 | 61 64 20 63 6f 6e 74 61 |ach thre|ad conta|
|00004570| 69 6e 73 20 61 20 70 6f | 69 6e 74 65 72 20 74 6f |ins a po|inter to|
|00004580| 20 74 68 65 20 61 70 70 | 6c 69 63 61 74 69 6f 6e | the app|lication|
|00004590| d5 73 20 67 6c 6f 62 61 | 6c 20 64 61 74 61 20 77 |.s globa|l data w|
|000045a0| 6f 72 6c 64 2e 20 57 68 | 65 6e 20 69 74 20 73 77 |orld. Wh|en it sw|
|000045b0| 69 74 63 68 65 73 20 63 | 6f 6e 74 65 78 74 73 2c |itches c|ontexts,|
|000045c0| 20 74 68 65 20 54 68 72 | 65 61 64 20 4d 61 6e 61 | the Thr|ead Mana|
|000045d0| 67 65 72 20 69 6e 69 74 | 69 61 6c 6c 79 20 73 65 |ger init|ially se|
|000045e0| 74 73 20 41 35 20 28 47 | 50 52 31 29 20 61 6e 64 |ts A5 (G|PR1) and|
|000045f0| 20 74 68 65 20 4d 4d 55 | 20 6d 6f 64 65 20 74 6f | the MMU| mode to|
|00004600| 20 74 68 65 20 73 61 6d | 65 20 76 61 6c 75 65 73 | the sam|e values|
|00004610| 20 61 73 20 74 68 6f 73 | 65 20 69 6e 20 74 68 65 | as thos|e in the|
|00004620| 20 6d 61 69 6e 20 74 68 | 72 65 61 64 2e 20 49 6e | main th|read. In|
|00004630| 20 74 68 69 73 20 77 61 | 79 20 61 6c 6c 20 74 68 | this wa|y all th|
|00004640| 72 65 61 64 73 20 63 61 | 6e 20 73 68 61 72 65 20 |reads ca|n share |
|00004650| 69 6e 20 74 68 65 20 61 | 70 70 6c 69 63 61 74 69 |in the a|pplicati|
|00004660| 6f 6e d5 73 20 67 6c 6f | 62 61 6c 20 64 61 74 61 |on.s glo|bal data|
|00004670| 20 77 6f 72 6c 64 2e 20 | 0d 54 61 62 6c 65 20 31 | world. |.Table 1|
|00004680| 2d 31 20 73 68 6f 77 73 | 20 74 68 65 20 72 65 67 |-1 shows| the reg|
|00004690| 69 73 74 65 72 73 20 74 | 68 61 74 20 74 68 65 20 |isters t|hat the |
|000046a0| 54 68 72 65 61 64 20 4d | 61 6e 61 67 65 72 20 73 |Thread M|anager s|
|000046b0| 61 76 65 73 20 66 6f 72 | 20 61 20 36 38 30 78 30 |aves for| a 680x0|
|000046c0| 20 61 70 70 6c 69 63 61 | 74 69 6f 6e 2e 20 0d 0d | applica|tion. ..|
|000046d0| 54 61 62 6c 65 20 31 2d | 31 09 52 65 67 69 73 74 |Table 1-|1.Regist|
|000046e0| 65 72 73 20 69 6e 20 74 | 68 65 20 36 38 30 78 30 |ers in t|he 680x0|
|000046f0| 20 64 65 66 61 75 6c 74 | 20 74 68 72 65 61 64 20 | default| thread |
|00004700| 63 6f 6e 74 65 78 74 0d | 43 50 55 20 72 65 67 69 |context.|CPU regi|
|00004710| 73 74 65 72 73 09 46 50 | 55 20 72 65 67 69 73 74 |sters.FP|U regist|
|00004720| 65 72 73 09 0d 44 30 d0 | 44 37 09 46 50 43 52 2c |ers..D0.|D7.FPCR,|
|00004730| 20 46 50 53 52 2c 20 46 | 50 49 41 52 09 0d 41 30 | FPSR, F|PIAR..A0|
|00004740| d0 41 37 09 46 50 30 d0 | 46 50 37 09 0d 53 52 20 |.A7.FP0.|FP7..SR |
|00004750| 28 69 6e 63 6c 75 64 69 | 6e 67 20 43 43 52 29 09 |(includi|ng CCR).|
|00004760| 46 50 55 20 66 72 61 6d | 65 09 0d 0d 0d 46 6f 72 |FPU fram|e....For|
|00004770| 20 36 38 30 78 30 20 61 | 70 70 6c 69 63 61 74 69 | 680x0 a|pplicati|
|00004780| 6f 6e 73 2c 20 77 68 65 | 6e 20 79 6f 75 20 63 72 |ons, whe|n you cr|
|00004790| 65 61 74 65 20 6f 72 20 | 61 6c 6c 6f 63 61 74 65 |eate or |allocate|
|000047a0| 20 61 20 74 68 72 65 61 | 64 20 77 69 74 68 20 74 | a threa|d with t|
|000047b0| 68 65 20 4e 65 77 54 68 | 72 65 61 64 20 66 75 6e |he NewTh|read fun|
|000047c0| 63 74 69 6f 6e 2c 20 74 | 68 65 20 54 68 72 65 61 |ction, t|he Threa|
|000047d0| 64 20 4d 61 6e 61 67 65 | 72 20 70 72 6f 76 69 64 |d Manage|r provid|
|000047e0| 65 73 20 61 6e 20 6f 70 | 74 69 6f 6e 20 74 68 61 |es an op|tion tha|
|000047f0| 74 20 61 6c 6c 6f 77 73 | 20 79 6f 75 20 74 6f 20 |t allows| you to |
|00004800| 63 72 65 61 74 65 20 61 | 20 74 68 72 65 61 64 20 |create a| thread |
|00004810| 77 68 6f 73 65 20 46 50 | 55 20 72 65 67 69 73 74 |whose FP|U regist|
|00004820| 65 72 73 20 61 72 65 20 | 6e 6f 74 20 74 6f 20 62 |ers are |not to b|
|00004830| 65 20 73 61 76 65 64 2e | 20 54 68 69 73 20 61 6c |e saved.| This al|
|00004840| 6c 6f 77 73 20 66 61 73 | 74 65 72 20 63 6f 6e 74 |lows fas|ter cont|
|00004850| 65 78 74 20 73 77 69 74 | 63 68 65 73 20 66 6f 72 |ext swit|ches for|
|00004860| 20 74 68 72 65 61 64 73 | 20 74 68 61 74 20 64 6f | threads| that do|
|00004870| 6e d5 74 20 75 73 65 20 | 74 68 65 20 46 50 55 20 |n.t use |the FPU |
|00004880| 72 65 67 69 73 74 65 72 | 73 2e 20 0d 46 6f 72 20 |register|s. .For |
|00004890| 50 6f 77 65 72 50 43 20 | 61 70 70 6c 69 63 61 74 |PowerPC |applicat|
|000048a0| 69 6f 6e 73 2c 20 74 68 | 65 20 54 68 72 65 61 64 |ions, th|e Thread|
|000048b0| 20 4d 61 6e 61 67 65 72 | 20 61 6c 77 61 79 73 20 | Manager| always |
|000048c0| 73 61 76 65 73 20 74 68 | 65 20 46 50 55 20 72 65 |saves th|e FPU re|
|000048d0| 67 69 73 74 65 72 73 2c | 20 72 65 67 61 72 64 6c |gisters,| regardl|
|000048e0| 65 73 73 20 6f 66 20 61 | 6e 79 20 6f 70 74 69 6f |ess of a|ny optio|
|000048f0| 6e 73 20 79 6f 75 20 73 | 65 74 20 62 65 63 61 75 |ns you s|et becau|
|00004900| 73 65 20 74 68 65 20 50 | 6f 77 65 72 50 43 20 70 |se the P|owerPC p|
|00004910| 72 6f 63 65 73 73 6f 72 | 20 63 61 6e 20 75 73 65 |rocessor| can use|
|00004920| 20 74 68 65 20 46 50 55 | 20 72 65 67 69 73 74 65 | the FPU| registe|
|00004930| 72 73 20 66 6f 72 20 6f | 70 74 69 6d 69 7a 61 74 |rs for o|ptimizat|
|00004940| 69 6f 6e 73 2e 0d 54 61 | 62 6c 65 20 31 2d 32 20 |ions..Ta|ble 1-2 |
|00004950| 73 68 6f 77 73 20 74 68 | 65 20 72 65 67 69 73 74 |shows th|e regist|
|00004960| 65 72 73 20 74 68 61 74 | 20 74 68 65 20 54 68 72 |ers that| the Thr|
|00004970| 65 61 64 20 6d 61 6e 61 | 67 65 72 20 73 61 76 65 |ead mana|ger save|
|00004980| 73 20 66 6f 72 20 61 20 | 50 6f 77 65 72 50 43 20 |s for a |PowerPC |
|00004990| 61 70 70 6c 69 63 61 74 | 69 6f 6e 2e 0d 0d 54 61 |applicat|ion...Ta|
|000049a0| 62 6c 65 20 31 2d 32 09 | 52 65 67 69 73 74 65 72 |ble 1-2.|Register|
|000049b0| 73 20 69 6e 20 74 68 65 | 20 50 6f 77 65 72 50 43 |s in the| PowerPC|
|000049c0| 20 64 65 66 61 75 6c 74 | 20 74 68 72 65 61 64 20 | default| thread |
|000049d0| 63 6f 6e 74 65 78 74 0d | 43 50 55 20 72 65 67 69 |context.|CPU regi|
|000049e0| 73 74 65 72 73 09 46 50 | 55 20 72 65 67 69 73 74 |sters.FP|U regist|
|000049f0| 65 72 73 09 4d 61 63 68 | 69 6e 65 20 72 65 67 69 |ers.Mach|ine regi|
|00004a00| 73 74 65 72 73 09 0d 52 | 30 d0 52 33 31 09 46 50 |sters..R|0.R31.FP|
|00004a10| 30 d0 46 50 33 31 09 43 | 54 52 2c 20 4c 52 2c 20 |0.FP31.C|TR, LR, |
|00004a20| 50 43 09 0d 09 46 50 53 | 43 52 09 43 52 2c 20 58 |PC...FPS|CR.CR, X|
|00004a30| 45 52 09 0d 0d 0d 0d 43 | 75 73 74 6f 6d 20 43 6f |ER.....C|ustom Co|
|00004a40| 6e 74 65 78 74 2d 53 77 | 69 74 63 68 69 6e 67 20 |ntext-Sw|itching |
|00004a50| 46 75 6e 63 74 69 6f 6e | 0d 0d 54 68 65 20 54 68 |Function|..The Th|
|00004a60| 72 65 61 64 20 4d 61 6e | 61 67 65 72 20 61 6c 6c |read Man|ager all|
|00004a70| 6f 77 73 20 79 6f 75 20 | 74 6f 20 69 6e 73 74 61 |ows you |to insta|
|00004a80| 6c 6c 20 61 20 63 75 73 | 74 6f 6d 20 63 6f 6e 74 |ll a cus|tom cont|
|00004a90| 65 78 74 2d 73 77 69 74 | 63 68 69 6e 67 20 66 75 |ext-swit|ching fu|
|00004aa0| 6e 63 74 69 6f 6e 20 74 | 6f 20 73 75 70 70 6c 65 |nction t|o supple|
|00004ab0| 6d 65 6e 74 20 74 68 65 | 20 63 6f 6e 74 65 78 74 |ment the| context|
|00004ac0| 20 69 6e 66 6f 72 6d 61 | 74 69 6f 6e 20 74 68 61 | informa|tion tha|
|00004ad0| 74 20 74 68 65 20 54 68 | 72 65 61 64 20 4d 61 6e |t the Th|read Man|
|00004ae0| 61 67 65 72 20 73 61 76 | 65 73 20 77 68 65 6e 20 |ager sav|es when |
|00004af0| 69 74 20 73 77 69 74 63 | 68 65 73 20 63 6f 6e 74 |it switc|hes cont|
|00004b00| 72 6f 6c 20 62 65 74 77 | 65 65 6e 20 6f 6e 65 20 |rol betw|een one |
|00004b10| 74 68 72 65 61 64 20 61 | 6e 64 20 61 6e 6f 74 68 |thread a|nd anoth|
|00004b20| 65 72 2e 20 54 68 69 73 | 20 73 65 63 74 69 6f 6e |er. This| section|
|00004b30| 20 64 65 73 63 72 69 62 | 65 73 20 68 6f 77 20 74 | describ|es how t|
|00004b40| 6f 20 69 6e 73 74 61 6c | 6c 20 61 20 63 75 73 74 |o instal|l a cust|
|00004b50| 6f 6d 20 63 6f 6e 74 65 | 78 74 2d 73 77 69 74 63 |om conte|xt-switc|
|00004b60| 68 69 6e 67 20 66 75 6e | 63 74 69 6f 6e 20 61 6e |hing fun|ction an|
|00004b70| 64 20 75 73 65 20 69 74 | 20 69 6e 20 63 6f 6e 6a |d use it| in conj|
|00004b80| 75 6e 63 74 69 6f 6e 20 | 77 69 74 68 20 74 68 65 |unction |with the|
|00004b90| 20 64 65 66 61 75 6c 74 | 20 63 6f 6e 74 65 78 74 | default| context|
|00004ba0| 2d 73 77 69 74 63 68 69 | 6e 67 20 6d 65 63 68 61 |-switchi|ng mecha|
|00004bb0| 6e 69 73 6d 2e 0d 59 6f | 75 20 69 6e 73 74 61 6c |nism..Yo|u instal|
|00004bc0| 6c 20 61 20 63 75 73 74 | 6f 6d 20 63 6f 6e 74 65 |l a cust|om conte|
|00004bd0| 78 74 2d 73 77 69 74 63 | 68 69 6e 67 20 66 75 6e |xt-switc|hing fun|
|00004be0| 63 74 69 6f 6e 20 77 69 | 74 68 20 74 68 65 20 53 |ction wi|th the S|
|00004bf0| 65 74 54 68 72 65 61 64 | 53 77 69 74 63 68 65 72 |etThread|Switcher|
|00004c00| 20 66 75 6e 63 74 69 6f | 6e 2e 20 59 6f 75 20 61 | functio|n. You a|
|00004c10| 73 73 69 67 6e 20 61 20 | 63 75 73 74 6f 6d 20 73 |ssign a |custom s|
|00004c20| 77 69 74 63 68 69 6e 67 | 20 66 75 6e 63 74 69 6f |witching| functio|
|00004c30| 6e 20 73 65 70 61 72 61 | 74 65 6c 79 20 74 6f 20 |n separa|tely to |
|00004c40| 65 61 63 68 20 74 68 72 | 65 61 64 2e 20 48 6f 77 |each thr|ead. How|
|00004c50| 65 76 65 72 2c 20 62 65 | 63 61 75 73 65 20 79 6f |ever, be|cause yo|
|00004c60| 75 20 61 6c 73 6f 20 70 | 61 73 73 20 61 20 70 61 |u also p|ass a pa|
|00004c70| 72 61 6d 65 74 65 72 20 | 63 6f 6e 74 61 69 6e 69 |rameter |containi|
|00004c80| 6e 67 20 74 68 72 65 61 | 64 20 73 70 65 63 69 66 |ng threa|d specif|
|00004c90| 69 63 20 69 6e 66 6f 72 | 6d 61 74 69 6f 6e 2c 20 |ic infor|mation, |
|00004ca0| 79 6f 75 20 63 61 6e 20 | 64 65 66 69 6e 65 20 61 |you can |define a|
|00004cb0| 20 73 69 6e 67 6c 65 20 | 73 77 69 74 63 68 69 6e | single |switchin|
|00004cc0| 67 20 66 75 6e 63 74 69 | 6f 6e 20 74 6f 20 61 73 |g functi|on to as|
|00004cd0| 73 69 67 6e 20 74 6f 20 | 61 6c 6c 20 74 68 72 65 |sign to |all thre|
|00004ce0| 61 64 73 20 61 6e 64 20 | 75 73 65 20 74 68 69 73 |ads and |use this|
|00004cf0| 20 70 61 72 61 6d 65 74 | 65 72 20 74 6f 20 70 61 | paramet|er to pa|
|00004d00| 73 73 20 73 70 65 63 69 | 66 69 63 20 69 6e 66 6f |ss speci|fic info|
|00004d10| 72 6d 61 74 69 6f 6e 20 | 74 6f 20 65 61 63 68 20 |rmation |to each |
|00004d20| 74 68 72 65 61 64 2e 20 | 0d 54 68 65 20 54 68 72 |thread. |.The Thr|
|00004d30| 65 61 64 20 4d 61 6e 61 | 67 65 72 20 63 61 6c 6c |ead Mana|ger call|
|00004d40| 73 20 74 68 65 20 63 75 | 73 74 6f 6d 20 63 6f 6e |s the cu|stom con|
|00004d50| 74 65 78 74 2d 73 77 69 | 74 63 68 69 6e 67 20 66 |text-swi|tching f|
|00004d60| 75 6e 63 74 69 6f 6e 2c | 20 4d 79 54 68 72 65 61 |unction,| MyThrea|
|00004d70| 64 53 77 69 74 63 68 50 | 72 6f 63 2c 20 77 68 65 |dSwitchP|roc, whe|
|00004d80| 6e 65 76 65 72 20 74 68 | 65 20 74 68 72 65 61 64 |never th|e thread|
|00004d90| 20 69 74 20 69 73 20 61 | 73 73 69 67 6e 65 64 20 | it is a|ssigned |
|00004da0| 74 6f 20 69 73 20 73 63 | 68 65 64 75 6c 65 64 2e |to is sc|heduled.|
|00004db0| 20 42 65 63 61 75 73 65 | 20 69 74 20 69 73 20 61 | Because| it is a|
|00004dc0| 20 d4 73 77 69 74 63 68 | 65 72 20 69 6e 6e 65 72 | .switch|er inner|
|00004dd0| d5 20 69 74 20 69 73 20 | 63 61 6c 6c 65 64 20 6a |. it is |called j|
|00004de0| 75 73 74 20 62 65 66 6f | 72 65 20 74 68 65 20 63 |ust befo|re the c|
|00004df0| 6f 64 65 20 73 74 61 72 | 74 73 20 65 78 65 63 75 |ode star|ts execu|
|00004e00| 74 69 6e 67 2e 20 54 68 | 65 20 54 68 72 65 61 64 |ting. Th|e Thread|
|00004e10| 20 4d 61 6e 61 67 65 72 | 20 63 61 6c 6c 73 20 61 | Manager| calls a|
|00004e20| 20 d4 73 77 69 74 63 68 | 65 72 20 6f 75 74 65 72 | .switch|er outer|
|00004e30| d5 20 63 75 73 74 6f 6d | 20 73 77 69 74 63 68 69 |. custom| switchi|
|00004e40| 6e 67 20 66 75 6e 63 74 | 69 6f 6e 20 6a 75 73 74 |ng funct|ion just|
|00004e50| 20 61 66 74 65 72 20 74 | 68 65 20 63 6f 64 65 20 | after t|he code |
|00004e60| 69 6e 20 74 68 65 20 74 | 68 72 65 61 64 20 73 74 |in the t|hread st|
|00004e70| 6f 70 73 20 65 78 65 63 | 75 74 69 6e 67 2e 20 46 |ops exec|uting. F|
|00004e80| 69 67 75 72 65 20 31 2d | 34 20 73 68 6f 77 73 20 |igure 1-|4 shows |
|00004e90| 77 68 65 6e 20 74 68 65 | 20 54 68 72 65 61 64 20 |when the| Thread |
|00004ea0| 4d 61 6e 61 67 65 72 20 | 63 61 6c 6c 73 20 65 61 |Manager |calls ea|
|00004eb0| 63 68 20 74 79 70 65 20 | 6f 66 20 63 75 73 74 6f |ch type |of custo|
|00004ec0| 6d 20 63 6f 6e 74 65 78 | 74 2d 73 77 69 74 63 68 |m contex|t-switch|
|00004ed0| 69 6e 67 20 66 75 6e 63 | 74 69 6f 6e 2e 0d 0d 46 |ing func|tion...F|
|00004ee0| 69 67 75 72 65 20 31 2d | 34 09 43 75 73 74 6f 6d |igure 1-|4.Custom|
|00004ef0| 20 63 6f 6e 74 65 78 74 | 2d 73 77 69 74 63 68 69 | context|-switchi|
|00004f00| 6e 67 20 66 75 6e 63 74 | 69 6f 6e 0d 0d 0d 54 68 |ng funct|ion...Th|
|00004f10| 72 65 61 64 20 53 74 61 | 63 6b 73 20 0d 0d 57 68 |read Sta|cks ..Wh|
|00004f20| 65 6e 20 74 68 65 20 50 | 72 6f 63 65 73 73 20 4d |en the P|rocess M|
|00004f30| 61 6e 61 67 65 72 20 6c | 61 75 6e 63 68 65 73 20 |anager l|aunches |
|00004f40| 61 20 74 68 72 65 61 64 | 65 64 20 61 70 70 6c 69 |a thread|ed appli|
|00004f50| 63 61 74 69 6f 6e 2c 20 | 69 74 20 63 72 65 61 74 |cation, |it creat|
|00004f60| 65 73 20 74 68 65 20 6d | 61 69 6e 20 74 68 72 65 |es the m|ain thre|
|00004f70| 61 64 20 61 6e 64 20 73 | 65 74 73 20 75 70 20 74 |ad and s|ets up t|
|00004f80| 68 65 20 73 74 61 63 6b | 20 66 6f 72 20 69 74 20 |he stack| for it |
|00004f90| 6a 75 73 74 20 6c 69 6b | 65 20 69 74 20 77 6f 75 |just lik|e it wou|
|00004fa0| 6c 64 20 66 6f 72 20 61 | 20 6e 6f 6e 74 68 72 65 |ld for a| nonthre|
|00004fb0| 61 64 65 64 20 61 70 70 | 6c 69 63 61 74 69 6f 6e |aded app|lication|
|00004fc0| 2e 20 59 6f 75 20 63 61 | 6e 20 65 78 70 61 6e 64 |. You ca|n expand|
|00004fd0| 20 74 68 69 73 20 73 74 | 61 63 6b 20 62 79 20 63 | this st|ack by c|
|00004fe0| 61 6c 6c 69 6e 67 20 74 | 68 65 20 4d 65 6d 6f 72 |alling t|he Memor|
|00004ff0| 79 20 4d 61 6e 61 67 65 | 72 20 53 65 74 41 70 70 |y Manage|r SetApp|
|00005000| 6c 4c 69 6d 69 74 20 66 | 75 6e 63 74 69 6f 6e 20 |lLimit f|unction |
|00005010| 61 74 20 74 68 65 20 62 | 65 67 69 6e 6e 69 6e 67 |at the b|eginning|
|00005020| 20 6f 66 20 79 6f 75 72 | 20 61 70 70 6c 69 63 61 | of your| applica|
|00005030| 74 69 6f 6e 2e 20 53 65 | 65 20 d2 57 6f 72 6b 69 |tion. Se|e .Worki|
|00005040| 6e 67 20 57 69 74 68 20 | 53 74 61 63 6b 73 d3 20 |ng With |Stacks. |
|00005050| 6f 6e 20 70 61 67 65 20 | 31 2d 32 31 20 66 6f 72 |on page |1-21 for|
|00005060| 20 61 6e 20 65 78 61 6d | 70 6c 65 20 6f 66 20 68 | an exam|ple of h|
|00005070| 6f 77 20 74 6f 20 75 73 | 65 20 74 68 69 73 20 66 |ow to us|e this f|
|00005080| 75 6e 63 74 69 6f 6e 2e | 20 0d 46 6f 72 20 65 61 |unction.| .For ea|
|00005090| 63 68 20 73 75 62 73 65 | 71 75 65 6e 74 20 74 68 |ch subse|quent th|
|000050a0| 72 65 61 64 20 74 68 61 | 74 20 79 6f 75 20 63 72 |read tha|t you cr|
|000050b0| 65 61 74 65 2c 20 74 68 | 65 20 54 68 72 65 61 64 |eate, th|e Thread|
|000050c0| 20 4d 61 6e 61 67 65 72 | 20 6d 61 69 6e 74 61 69 | Manager| maintai|
|000050d0| 6e 73 20 61 20 73 65 70 | 61 72 61 74 65 20 73 74 |ns a sep|arate st|
|000050e0| 61 63 6b 20 69 6e 20 79 | 6f 75 72 20 61 70 70 6c |ack in y|our appl|
|000050f0| 69 63 61 74 69 6f 6e 20 | 68 65 61 70 20 61 72 65 |ication |heap are|
|00005100| 61 2e 20 0d 4e 6f 74 65 | 0d 42 65 63 61 75 73 65 |a. .Note|.Because|
|00005110| 20 74 68 65 20 54 68 72 | 65 61 64 20 4d 61 6e 61 | the Thr|ead Mana|
|00005120| 67 65 72 20 64 6f 65 73 | 20 6e 6f 74 20 6d 6f 76 |ger does| not mov|
|00005130| 65 20 73 74 61 63 6b 73 | 20 64 75 72 69 6e 67 20 |e stacks| during |
|00005140| 61 20 74 68 72 65 61 64 | 20 63 6f 6e 74 65 78 74 |a thread| context|
|00005150| 20 73 77 69 74 63 68 2c | 20 79 6f 75 20 63 61 6e | switch,| you can|
|00005160| 20 70 61 73 73 20 66 75 | 6e 63 74 69 6f 6e 20 70 | pass fu|nction p|
|00005170| 61 72 61 6d 65 74 65 72 | 73 20 6f 6e 20 74 68 65 |arameter|s on the|
|00005180| 20 73 74 61 63 6b 2e 13 | 75 0d 0d 59 6f 75 20 73 | stack..|u..You s|
|00005190| 70 65 63 69 66 79 20 74 | 68 65 20 73 74 61 63 6b |pecify t|he stack|
|000051a0| 20 73 69 7a 65 20 77 68 | 65 6e 20 79 6f 75 20 63 | size wh|en you c|
|000051b0| 72 65 61 74 65 20 61 20 | 6e 65 77 20 74 68 72 65 |reate a |new thre|
|000051c0| 61 64 20 77 69 74 68 20 | 74 68 65 20 43 72 65 61 |ad with |the Crea|
|000051d0| 74 65 54 68 72 65 61 64 | 50 6f 6f 6c 20 6f 72 20 |teThread|Pool or |
|000051e0| 4e 65 77 54 68 72 65 61 | 64 20 66 75 6e 63 74 69 |NewThrea|d functi|
|000051f0| 6f 6e 2e 20 54 68 65 20 | 73 74 61 63 6b 20 6d 75 |on. The |stack mu|
|00005200| 73 74 20 62 65 20 6c 61 | 72 67 65 20 65 6e 6f 75 |st be la|rge enou|
|00005210| 67 68 20 74 6f 20 68 61 | 6e 64 6c 65 20 73 61 76 |gh to ha|ndle sav|
|00005220| 65 64 20 74 68 72 65 61 | 64 20 63 6f 6e 74 65 78 |ed threa|d contex|
|00005230| 74 2c 20 6e 6f 72 6d 61 | 6c 20 61 70 70 6c 69 63 |t, norma|l applic|
|00005240| 61 74 69 6f 6e 20 73 74 | 61 63 6b 20 75 73 61 67 |ation st|ack usag|
|00005250| 65 2c 20 69 6e 74 65 72 | 72 75 70 74 20 68 61 6e |e, inter|rupt han|
|00005260| 64 6c 69 6e 67 20 72 6f | 75 74 69 6e 65 73 2c 20 |dling ro|utines, |
|00005270| 61 6e 64 20 43 50 55 20 | 65 78 63 65 70 74 69 6f |and CPU |exceptio|
|00005280| 6e 73 2e 20 59 6f 75 20 | 63 61 6e 20 73 70 65 63 |ns. You |can spec|
|00005290| 69 66 79 20 61 20 70 61 | 72 74 69 63 75 6c 61 72 |ify a pa|rticular|
|000052a0| 20 73 69 7a 65 20 69 6e | 20 62 79 74 65 73 20 6f | size in| bytes o|
|000052b0| 72 20 75 73 65 20 74 68 | 65 20 64 65 66 61 75 6c |r use th|e defaul|
|000052c0| 74 20 73 69 7a 65 20 74 | 68 61 74 20 74 68 65 20 |t size t|hat the |
|000052d0| 54 68 72 65 61 64 20 4d | 61 6e 61 67 65 72 20 73 |Thread M|anager s|
|000052e0| 75 70 70 6c 69 65 73 20 | 66 6f 72 20 61 20 74 68 |upplies |for a th|
|000052f0| 72 65 61 64 2e 20 54 68 | 65 20 64 65 66 61 75 6c |read. Th|e defaul|
|00005300| 74 20 73 69 7a 65 20 69 | 73 20 6d 6f 72 65 20 74 |t size i|s more t|
|00005310| 68 61 6e 20 61 64 65 71 | 75 61 74 65 20 66 6f 72 |han adeq|uate for|
|00005320| 20 6d 6f 73 74 20 74 68 | 72 65 61 64 73 2e 20 0d | most th|reads. .|
|00005330| 0d 43 72 65 61 74 69 6e | 67 20 61 6e 64 20 44 69 |.Creatin|g and Di|
|00005340| 73 70 6f 73 69 6e 67 20 | 6f 66 20 54 68 72 65 61 |sposing |of Threa|
|00005350| 64 73 0d 0d 54 68 65 72 | 65 20 61 72 65 20 74 77 |ds..Ther|e are tw|
|00005360| 6f 20 77 61 79 73 20 74 | 6f 20 63 72 65 61 74 65 |o ways t|o create|
|00005370| 20 74 68 72 65 61 64 73 | 20 77 69 74 68 20 63 61 | threads| with ca|
|00005380| 6c 6c 73 20 74 6f 20 74 | 68 65 20 54 68 72 65 61 |lls to t|he Threa|
|00005390| 64 20 4d 61 6e 61 67 65 | 72 2e 20 4f 6e 65 20 69 |d Manage|r. One i|
|000053a0| 73 20 74 6f 20 75 73 65 | 20 74 68 65 20 4e 65 77 |s to use| the New|
|000053b0| 54 68 72 65 61 64 20 66 | 75 6e 63 74 69 6f 6e 20 |Thread f|unction |
|000053c0| 74 6f 20 63 72 65 61 74 | 65 20 61 20 73 69 6e 67 |to creat|e a sing|
|000053d0| 6c 65 20 74 68 72 65 61 | 64 2e 20 54 68 65 20 6f |le threa|d. The o|
|000053e0| 74 68 65 72 20 77 61 79 | 20 69 73 20 74 6f 20 63 |ther way| is to c|
|000053f0| 61 6c 6c 20 74 68 65 20 | 43 72 65 61 74 65 54 68 |all the |CreateTh|
|00005400| 72 65 61 64 50 6f 6f 6c | 20 66 75 6e 63 74 69 6f |readPool| functio|
|00005410| 6e 20 74 6f 20 63 72 65 | 61 74 65 20 61 20 70 6f |n to cre|ate a po|
|00005420| 6f 6c 20 6f 66 20 74 68 | 72 65 61 64 73 20 74 68 |ol of th|reads th|
|00005430| 61 74 20 79 6f 75 20 6c | 61 74 65 72 20 61 6c 6c |at you l|ater all|
|00005440| 6f 63 61 74 65 20 77 69 | 74 68 20 74 68 65 20 4e |ocate wi|th the N|
|00005450| 65 77 54 68 72 65 61 64 | 20 66 75 6e 63 74 69 6f |ewThread| functio|
|00005460| 6e 2e 20 54 68 65 20 61 | 64 76 61 6e 74 61 67 65 |n. The a|dvantage|
|00005470| 20 6f 66 20 74 68 65 20 | 6c 61 74 74 65 72 20 6d | of the |latter m|
|00005480| 65 74 68 6f 64 20 69 73 | 20 74 68 61 74 20 79 6f |ethod is| that yo|
|00005490| 75 20 68 61 6e 64 6c 65 | 20 6d 65 6d 6f 72 79 20 |u handle| memory |
|000054a0| 61 6c 6c 6f 63 61 74 69 | 6f 6e 20 75 70 20 66 72 |allocati|on up fr|
|000054b0| 6f 6e 74 20 62 65 66 6f | 72 65 20 66 72 61 67 6d |ont befo|re fragm|
|000054c0| 65 6e 74 61 74 69 6f 6e | 20 6f 63 63 75 72 73 2e |entation| occurs.|
|000054d0| 20 0d 57 68 65 6e 20 79 | 6f 75 20 63 72 65 61 74 | .When y|ou creat|
|000054e0| 65 20 6f 72 20 61 6c 6c | 6f 63 61 74 65 20 61 20 |e or all|ocate a |
|000054f0| 74 68 72 65 61 64 20 77 | 69 74 68 20 74 68 65 20 |thread w|ith the |
|00005500| 4e 65 77 54 68 72 65 61 | 64 20 66 75 6e 63 74 69 |NewThrea|d functi|
|00005510| 6f 6e 2c 20 79 6f 75 20 | 73 70 65 63 69 66 79 2c |on, you |specify,|
|00005520| 20 61 6d 6f 6e 67 20 6f | 74 68 65 72 20 74 68 69 | among o|ther thi|
|00005530| 6e 67 73 2c 20 74 68 65 | 20 73 74 61 63 6b 20 73 |ngs, the| stack s|
|00005540| 69 7a 65 2e 20 59 6f 75 | 20 61 6c 73 6f 20 69 64 |ize. You| also id|
|00005550| 65 6e 74 69 66 79 20 74 | 68 65 20 66 75 6e 63 74 |entify t|he funct|
|00005560| 69 6f 6e 20 74 68 61 74 | 20 69 73 20 74 68 65 20 |ion that| is the |
|00005570| 65 6e 74 72 79 20 70 6f | 69 6e 74 20 74 6f 20 74 |entry po|int to t|
|00005580| 68 65 20 74 68 72 65 61 | 64 20 61 6e 64 20 63 61 |he threa|d and ca|
|00005590| 6e 20 70 61 73 73 20 69 | 74 20 64 61 74 61 20 69 |n pass i|t data i|
|000055a0| 66 20 79 6f 75 20 77 69 | 73 68 2e 20 59 6f 75 20 |f you wi|sh. You |
|000055b0| 63 61 6e 20 61 6c 73 6f | 20 61 6c 6c 6f 63 61 74 |can also| allocat|
|000055c0| 65 20 73 74 6f 72 61 67 | 65 20 74 68 61 74 20 79 |e storag|e that y|
|000055d0| 6f 75 20 63 61 6e 20 75 | 73 65 20 74 6f 20 73 74 |ou can u|se to st|
|000055e0| 6f 72 65 20 74 68 65 20 | 74 68 72 65 61 64 20 72 |ore the |thread r|
|000055f0| 65 73 75 6c 74 2e 20 0d | 57 68 65 6e 20 61 20 74 |esult. .|When a t|
|00005600| 68 72 65 61 64 20 66 69 | 6e 69 73 68 65 73 20 65 |hread fi|nishes e|
|00005610| 78 65 63 75 74 69 6e 67 | 20 69 74 73 20 63 6f 64 |xecuting| its cod|
|00005620| 65 2c 20 74 68 65 20 54 | 68 72 65 61 64 20 4d 61 |e, the T|hread Ma|
|00005630| 6e 61 67 65 72 20 61 75 | 74 6f 6d 61 74 69 63 61 |nager au|tomatica|
|00005640| 6c 6c 79 20 63 61 6c 6c | 73 20 74 68 65 20 44 69 |lly call|s the Di|
|00005650| 73 70 6f 73 65 54 68 72 | 65 61 64 20 66 75 6e 63 |sposeThr|ead func|
|00005660| 74 69 6f 6e 20 74 6f 20 | 63 6c 65 61 6e 20 75 70 |tion to |clean up|
|00005670| 20 61 66 74 65 72 20 74 | 68 65 20 74 68 72 65 61 | after t|he threa|
|00005680| 64 2e 20 54 68 65 20 44 | 69 73 70 6f 73 65 54 68 |d. The D|isposeTh|
|00005690| 72 65 61 64 20 66 75 6e | 63 74 69 6f 6e 20 65 69 |read fun|ction ei|
|000056a0| 74 68 65 72 20 72 65 6d | 6f 76 65 73 20 74 68 65 |ther rem|oves the|
|000056b0| 20 74 68 72 65 61 64 20 | 65 6e 74 69 72 65 6c 79 | thread |entirely|
|000056c0| 20 28 74 68 65 20 64 65 | 66 61 75 6c 74 20 66 6f | (the de|fault fo|
|000056d0| 72 20 63 6f 6f 70 65 72 | 61 74 69 76 65 20 74 68 |r cooper|ative th|
|000056e0| 72 65 61 64 73 29 20 6f | 72 20 72 65 63 79 63 6c |reads) o|r recycl|
|000056f0| 65 73 20 74 68 65 20 74 | 68 72 65 61 64 20 69 6e |es the t|hread in|
|00005700| 74 6f 20 74 68 65 20 74 | 68 72 65 61 64 20 70 6f |to the t|hread po|
|00005710| 6f 6c 2e 20 59 6f 75 20 | 63 61 6e 20 63 61 6c 6c |ol. You |can call|
|00005720| 20 44 69 73 70 6f 73 65 | 54 68 72 65 61 64 20 79 | Dispose|Thread y|
|00005730| 6f 75 72 73 65 6c 66 20 | 69 66 20 79 6f 75 20 77 |ourself |if you w|
|00005740| 61 6e 74 20 74 6f 20 72 | 65 63 79 63 6c 65 20 61 |ant to r|ecycle a|
|00005750| 20 63 6f 6f 70 65 72 61 | 74 69 76 65 20 74 68 72 | coopera|tive thr|
|00005760| 65 61 64 20 69 6e 74 6f | 20 74 68 65 20 74 68 72 |ead into| the thr|
|00005770| 65 61 64 20 70 6f 6f 6c | 2e 0d 54 68 65 20 44 69 |ead pool|..The Di|
|00005780| 73 70 6f 73 65 54 68 72 | 65 61 64 20 66 75 6e 63 |sposeThr|ead func|
|00005790| 74 69 6f 6e 20 70 61 73 | 73 65 73 20 61 20 70 61 |tion pas|ses a pa|
|000057a0| 72 61 6d 65 74 65 72 20 | 62 61 63 6b 20 74 6f 20 |rameter |back to |
|000057b0| 74 68 65 20 4e 65 77 54 | 68 72 65 61 64 20 66 75 |the NewT|hread fu|
|000057c0| 6e 63 74 69 6f 6e 20 74 | 68 61 74 20 69 6e 69 74 |nction t|hat init|
|000057d0| 69 61 6c 6c 79 20 63 72 | 65 61 74 65 64 20 61 6e |ially cr|eated an|
|000057e0| 64 20 6c 61 75 6e 63 68 | 65 64 20 74 68 65 20 74 |d launch|ed the t|
|000057f0| 68 72 65 61 64 2e 20 49 | 74 20 70 6c 61 63 65 73 |hread. I|t places|
|00005800| 20 74 68 65 20 69 6e 66 | 6f 72 6d 61 74 69 6f 6e | the inf|ormation|
|00005810| 20 66 72 6f 6d 20 74 68 | 69 73 20 70 61 72 61 6d | from th|is param|
|00005820| 65 74 65 72 20 69 6e 20 | 74 68 65 20 73 74 6f 72 |eter in |the stor|
|00005830| 61 67 65 20 74 68 61 74 | 20 74 68 65 20 4e 65 77 |age that| the New|
|00005840| 54 68 72 65 61 64 20 66 | 75 6e 63 74 69 6f 6e 20 |Thread f|unction |
|00005850| 61 6c 6c 6f 63 61 74 65 | 64 20 77 68 65 6e 20 69 |allocate|d when i|
|00005860| 74 20 66 69 72 73 74 20 | 63 72 65 61 74 65 64 20 |t first |created |
|00005870| 74 68 65 20 74 68 72 65 | 61 64 2e 20 59 6f 75 20 |the thre|ad. You |
|00005880| 63 61 6e 20 75 73 65 20 | 74 68 69 73 20 70 61 72 |can use |this par|
|00005890| 61 6d 65 74 65 72 20 74 | 6f 20 70 61 73 73 20 74 |ameter t|o pass t|
|000058a0| 68 65 20 74 68 72 65 61 | 64 20 72 65 73 75 6c 74 |he threa|d result|
|000058b0| 20 62 61 63 6b 20 74 6f | 20 74 68 65 20 63 61 6c | back to| the cal|
|000058c0| 6c 69 6e 67 20 74 68 72 | 65 61 64 2c 20 69 66 20 |ling thr|ead, if |
|000058d0| 79 6f 75 20 77 69 73 68 | 2e 20 46 6f 72 20 65 78 |you wish|. For ex|
|000058e0| 61 6d 70 6c 65 2c 20 69 | 66 20 79 6f 75 20 63 61 |ample, i|f you ca|
|000058f0| 6c 6c 20 61 20 66 75 6e | 63 74 69 6f 6e 20 74 6f |ll a fun|ction to|
|00005900| 20 70 65 72 66 6f 72 6d | 20 61 20 63 61 6c 63 75 | perform| a calcu|
|00005910| 6c 61 74 69 6f 6e 20 6f | 72 20 70 72 6f 63 65 73 |lation o|r proces|
|00005920| 73 20 64 61 74 61 2c 20 | 79 6f 75 20 63 61 6e 20 |s data, |you can |
|00005930| 75 73 65 20 74 68 65 20 | 44 69 73 70 6f 73 65 54 |use the |DisposeT|
|00005940| 68 72 65 61 64 20 66 75 | 6e 63 74 69 6f 6e 20 74 |hread fu|nction t|
|00005950| 6f 20 70 61 73 73 20 74 | 68 65 20 72 65 73 75 6c |o pass t|he resul|
|00005960| 74 20 62 61 63 6b 2e 0d | 53 65 65 20 d2 50 61 73 |t back..|See .Pas|
|00005970| 73 69 6e 67 20 49 6e 70 | 75 74 20 61 6e 64 20 4f |sing Inp|ut and O|
|00005980| 75 74 70 75 74 20 50 61 | 72 61 6d 65 74 65 72 73 |utput Pa|rameters|
|00005990| 20 74 6f 20 61 20 4e 65 | 77 20 54 68 72 65 61 64 | to a Ne|w Thread|
|000059a0| d3 20 62 65 67 69 6e 6e | 69 6e 67 20 6f 6e 20 70 |. beginn|ing on p|
|000059b0| 61 67 65 20 31 2d 32 34 | 20 66 6f 72 20 69 6e 66 |age 1-24| for inf|
|000059c0| 6f 72 6d 61 74 69 6f 6e | 20 6f 6e 20 68 6f 77 20 |ormation| on how |
|000059d0| 74 6f 20 72 65 74 75 72 | 6e 20 64 61 74 61 20 66 |to retur|n data f|
|000059e0| 72 6f 6d 20 61 20 74 68 | 72 65 61 64 20 74 6f 20 |rom a th|read to |
|000059f0| 74 68 65 20 74 68 72 65 | 61 64 20 74 68 61 74 20 |the thre|ad that |
|00005a00| 6c 61 75 6e 63 68 65 64 | 20 69 74 2e 0d 0d 55 73 |launched| it...Us|
|00005a10| 69 6e 67 20 74 68 65 20 | 54 68 72 65 61 64 20 4d |ing the |Thread M|
|00005a20| 61 6e 61 67 65 72 0d 0d | 54 68 69 73 20 73 65 63 |anager..|This sec|
|00005a30| 74 69 6f 6e 20 64 65 73 | 63 72 69 62 65 73 20 68 |tion des|cribes h|
|00005a40| 6f 77 20 79 6f 75 20 63 | 61 6e 20 74 61 6b 65 20 |ow you c|an take |
|00005a50| 61 64 76 61 6e 74 61 67 | 65 20 6f 66 20 74 68 65 |advantag|e of the|
|00005a60| 20 54 68 72 65 61 64 20 | 4d 61 6e 61 67 65 72 20 | Thread |Manager |
|00005a70| 74 6f 20 63 72 65 61 74 | 65 20 74 68 72 65 61 64 |to creat|e thread|
|00005a80| 65 64 20 61 70 70 6c 69 | 63 61 74 69 6f 6e 73 2e |ed appli|cations.|
|00005a90| 20 49 74 20 64 65 73 63 | 72 69 62 65 73 20 68 6f | It desc|ribes ho|
|00005aa0| 77 20 74 6f 20 0d 6e 09 | 75 73 65 20 74 68 65 20 |w to .n.|use the |
|00005ab0| 47 65 73 74 61 6c 74 20 | 4d 61 6e 61 67 65 72 20 |Gestalt |Manager |
|00005ac0| 74 6f 20 64 65 74 65 72 | 6d 69 6e 65 20 69 66 20 |to deter|mine if |
|00005ad0| 74 68 65 20 54 68 72 65 | 61 64 20 4d 61 6e 61 67 |the Thre|ad Manag|
|00005ae0| 65 72 20 69 73 20 61 76 | 61 69 6c 61 62 6c 65 20 |er is av|ailable |
|00005af0| 61 6e 64 20 77 68 69 63 | 68 20 66 65 61 74 75 72 |and whic|h featur|
|00005b00| 65 73 20 61 72 65 20 73 | 75 70 70 6f 72 74 65 64 |es are s|upported|
|00005b10| 0d 6e 09 63 72 65 61 74 | 65 20 61 20 74 68 72 65 |.n.creat|e a thre|
|00005b20| 61 64 20 70 6f 6f 6c 20 | 61 6e 64 20 61 6c 6c 6f |ad pool |and allo|
|00005b30| 63 61 74 65 20 61 6e 64 | 20 72 75 6e 20 74 68 72 |cate and| run thr|
|00005b40| 65 61 64 73 0d 6e 09 74 | 75 72 6e 20 6f 66 66 20 |eads.n.t|urn off |
|00005b50| 73 63 68 65 64 75 6c 69 | 6e 67 20 69 6e 20 63 72 |scheduli|ng in cr|
|00005b60| 69 74 69 63 61 6c 20 73 | 65 63 74 69 6f 6e 73 20 |itical s|ections |
|00005b70| 6f 66 20 63 6f 64 65 20 | 0d 6e 09 63 72 65 61 74 |of code |.n.creat|
|00005b80| 65 20 64 69 61 6c 6f 67 | 20 62 6f 78 65 73 20 74 |e dialog| boxes t|
|00005b90| 68 61 74 20 6c 65 61 76 | 65 20 61 6e 20 61 70 70 |hat leav|e an app|
|00005ba0| 6c 69 63 61 74 69 6f 6e | 20 66 72 65 65 20 74 6f |lication| free to|
|00005bb0| 20 64 6f 20 6f 74 68 65 | 72 20 77 6f 72 6b 0d 6e | do othe|r work.n|
|00005bc0| 09 70 61 73 73 20 70 61 | 72 61 6d 65 74 65 72 73 |.pass pa|rameters|
|00005bd0| 20 62 65 74 77 65 65 6e | 20 74 68 72 65 61 64 73 | between| threads|
|00005be0| 0d 6e 09 75 73 65 20 74 | 68 72 65 61 64 73 20 77 |.n.use t|hreads w|
|00005bf0| 69 74 68 20 61 73 79 6e | 63 68 72 6f 6e 6f 75 73 |ith asyn|chronous|
|00005c00| 20 49 2f 4f 20 72 6f 75 | 74 69 6e 65 73 0d 0d 0d | I/O rou|tines...|
|00005c10| 44 65 74 65 72 6d 69 6e | 69 6e 67 20 41 74 74 72 |Determin|ing Attr|
|00005c20| 69 62 75 74 65 73 20 6f | 66 20 74 68 65 20 54 68 |ibutes o|f the Th|
|00005c30| 72 65 61 64 20 4d 61 6e | 61 67 65 72 0d 0d 54 6f |read Man|ager..To|
|00005c40| 20 64 65 74 65 72 6d 69 | 6e 65 20 69 66 20 74 68 | determi|ne if th|
|00005c50| 65 20 54 68 72 65 61 64 | 20 4d 61 6e 61 67 65 72 |e Thread| Manager|
|00005c60| 20 69 73 20 61 76 61 69 | 6c 61 62 6c 65 20 61 6e | is avai|lable an|
|00005c70| 64 20 77 68 69 63 68 20 | 66 65 61 74 75 72 65 73 |d which |features|
|00005c80| 20 61 72 65 20 73 75 70 | 70 6f 72 74 65 64 2c 20 | are sup|ported, |
|00005c90| 63 61 6c 6c 20 74 68 65 | 20 47 65 73 74 61 6c 74 |call the| Gestalt|
|00005ca0| 20 66 75 6e 63 74 69 6f | 6e 20 77 69 74 68 20 74 | functio|n with t|
|00005cb0| 68 65 20 73 65 6c 65 63 | 74 6f 72 20 67 65 73 74 |he selec|tor gest|
|00005cc0| 61 6c 74 54 68 72 65 61 | 64 4d 67 72 41 74 74 72 |altThrea|dMgrAttr|
|00005cd0| 2e 20 54 68 65 20 47 65 | 73 74 61 6c 74 20 66 75 |. The Ge|stalt fu|
|00005ce0| 6e 63 74 69 6f 6e 20 72 | 65 74 75 72 6e 73 20 69 |nction r|eturns i|
|00005cf0| 6e 66 6f 72 6d 61 74 69 | 6f 6e 20 62 79 20 73 65 |nformati|on by se|
|00005d00| 74 74 69 6e 67 20 6f 72 | 20 63 6c 65 61 72 69 6e |tting or| clearin|
|00005d10| 67 20 62 69 74 73 20 69 | 6e 20 74 68 65 20 72 65 |g bits i|n the re|
|00005d20| 73 70 6f 6e 73 65 20 70 | 61 72 61 6d 65 74 65 72 |sponse p|arameter|
|00005d30| 2e 20 54 68 65 20 66 6f | 6c 6c 6f 77 69 6e 67 20 |. The fo|llowing |
|00005d40| 63 6f 6e 73 74 61 6e 74 | 73 20 64 65 66 69 6e 65 |constant|s define|
|00005d50| 20 74 68 65 20 62 69 74 | 73 20 63 75 72 72 65 6e | the bit|s curren|
|00005d60| 74 6c 79 20 75 73 65 64 | 2e 0d 65 6e 75 6d 20 7b |tly used|..enum {|
|00005d70| 09 09 09 09 09 09 09 09 | 09 09 09 09 09 2f 2a 20 |........|...../* |
|00005d80| 47 65 73 74 61 6c 74 20 | 73 65 6c 65 63 74 6f 72 |Gestalt |selector|
|00005d90| 73 20 2a 2f 0d 23 64 65 | 66 69 6e 65 20 67 65 73 |s */.#de|fine ges|
|00005da0| 74 61 6c 74 54 68 72 65 | 61 64 4d 67 72 41 74 74 |taltThre|adMgrAtt|
|00005db0| 72 09 09 09 09 09 09 09 | 09 09 09 27 74 68 64 73 |r.......|...'thds|
|00005dc0| 27 09 09 09 2f 2a 20 54 | 68 72 65 61 64 20 4d 61 |'.../* T|hread Ma|
|00005dd0| 6e 61 67 65 72 20 61 74 | 74 72 69 62 75 74 65 73 |nager at|tributes|
|00005de0| 20 2a 2f 0d 09 67 65 73 | 74 61 6c 74 54 68 72 65 | */..ges|taltThre|
|00005df0| 61 64 4d 67 72 50 72 65 | 73 65 6e 74 09 09 09 09 |adMgrPre|sent....|
|00005e00| 09 09 09 09 09 09 3d 20 | 30 2c 09 09 0d 09 67 65 |......= |0,....ge|
|00005e10| 73 74 61 6c 74 53 70 65 | 63 69 66 69 63 4d 61 74 |staltSpe|cificMat|
|00005e20| 63 68 53 75 70 70 6f 72 | 74 09 09 09 09 09 09 09 |chSuppor|t.......|
|00005e30| 09 09 09 3d 20 31 2c 09 | 09 0d 09 67 65 73 74 61 |...= 1,.|...gesta|
|00005e40| 6c 74 54 68 72 65 61 64 | 73 4c 69 62 72 61 72 79 |ltThread|sLibrary|
|00005e50| 50 72 65 73 65 6e 74 09 | 09 09 09 09 09 09 09 09 |Present.|........|
|00005e60| 09 3d 20 32 09 09 0d 7d | 3b 0d 67 65 73 74 61 6c |.= 2...}|;.gestal|
|00005e70| 74 54 68 72 65 61 64 4d | 67 72 50 72 65 73 65 6e |tThreadM|grPresen|
|00005e80| 74 0d 54 68 69 73 20 62 | 69 74 20 69 73 20 73 65 |t.This b|it is se|
|00005e90| 74 20 69 66 20 74 68 65 | 20 54 68 72 65 61 64 20 |t if the| Thread |
|00005ea0| 4d 61 6e 61 67 65 72 20 | 69 73 20 70 72 65 73 65 |Manager |is prese|
|00005eb0| 6e 74 2e 0d 67 65 73 74 | 61 6c 74 53 70 65 63 69 |nt..gest|altSpeci|
|00005ec0| 66 69 63 4d 61 74 63 68 | 53 75 70 70 6f 72 74 0d |ficMatch|Support.|
|00005ed0| 54 68 69 73 20 62 69 74 | 20 69 73 20 73 65 74 20 |This bit| is set |
|00005ee0| 69 66 20 74 68 65 20 54 | 68 72 65 61 64 20 4d 61 |if the T|hread Ma|
|00005ef0| 6e 61 67 65 72 20 73 75 | 70 70 6f 72 74 73 20 74 |nager su|pports t|
|00005f00| 68 65 20 61 6c 6c 6f 63 | 61 74 69 6f 6e 20 6f 66 |he alloc|ation of|
|00005f10| 20 74 68 72 65 61 64 73 | 20 62 61 73 65 64 20 6f | threads| based o|
|00005f20| 6e 20 61 6e 20 65 78 61 | 63 74 20 6d 61 74 63 68 |n an exa|ct match|
|00005f30| 20 77 69 74 68 20 74 68 | 65 20 72 65 71 75 65 73 | with th|e reques|
|00005f40| 74 65 64 20 73 74 61 63 | 6b 20 73 69 7a 65 2e 20 |ted stac|k size. |
|00005f50| 49 66 20 74 68 69 73 20 | 62 69 74 20 69 73 20 6e |If this |bit is n|
|00005f60| 6f 74 20 73 65 74 2c 20 | 74 68 65 20 54 68 72 65 |ot set, |the Thre|
|00005f70| 61 64 20 4d 61 6e 61 67 | 65 72 20 61 6c 6c 6f 63 |ad Manag|er alloc|
|00005f80| 61 74 65 73 20 74 68 72 | 65 61 64 73 20 62 61 73 |ates thr|eads bas|
|00005f90| 65 64 20 6f 6e 20 74 68 | 65 20 63 6c 6f 73 65 73 |ed on th|e closes|
|00005fa0| 74 20 6d 61 74 63 68 20 | 74 6f 20 74 68 65 20 72 |t match |to the r|
|00005fb0| 65 71 75 65 73 74 65 64 | 20 73 74 61 63 6b 20 73 |equested| stack s|
|00005fc0| 69 7a 65 2e 0d 67 65 73 | 74 61 6c 74 54 68 72 65 |ize..ges|taltThre|
|00005fd0| 61 64 73 4c 69 62 72 61 | 72 79 50 72 65 73 65 6e |adsLibra|ryPresen|
|00005fe0| 74 0d 54 68 69 73 20 62 | 69 74 20 69 73 20 73 65 |t.This b|it is se|
|00005ff0| 74 20 69 66 20 74 68 65 | 20 6e 61 74 69 76 65 20 |t if the| native |
|00006000| 76 65 72 73 69 6f 6e 20 | 6f 66 20 74 68 65 20 74 |version |of the t|
|00006010| 68 72 65 61 64 73 20 6c | 69 62 72 61 72 79 20 68 |hreads l|ibrary h|
|00006020| 61 73 20 62 65 65 6e 20 | 6c 6f 61 64 65 64 2e 0d |as been |loaded..|
|00006030| 0d 43 72 65 61 74 69 6e | 67 20 61 6e 64 20 41 6c |.Creatin|g and Al|
|00006040| 6c 6f 63 61 74 69 6e 67 | 20 61 20 54 68 72 65 61 |locating| a Threa|
|00006050| 64 0d 0d 54 68 69 73 20 | 73 65 63 74 69 6f 6e 20 |d..This |section |
|00006060| 73 68 6f 77 73 20 79 6f | 75 20 68 6f 77 20 74 6f |shows yo|u how to|
|00006070| 20 63 72 65 61 74 65 20 | 61 20 70 6f 6f 6c 20 6f | create |a pool o|
|00006080| 66 20 74 68 72 65 61 64 | 73 2c 20 61 6c 6c 6f 63 |f thread|s, alloc|
|00006090| 61 74 65 20 61 20 74 68 | 72 65 61 64 20 66 72 6f |ate a th|read fro|
|000060a0| 6d 20 74 68 61 74 20 70 | 6f 6f 6c 2c 20 61 6e 64 |m that p|ool, and|
|000060b0| 20 67 65 74 20 74 68 69 | 73 20 74 68 72 65 61 64 | get thi|s thread|
|000060c0| 20 74 6f 20 72 75 6e 2e | 20 54 68 65 20 63 6f 64 | to run.| The cod|
|000060d0| 65 20 73 61 6d 70 6c 65 | 73 20 69 6e 20 74 68 69 |e sample|s in thi|
|000060e0| 73 20 73 65 63 74 69 6f | 6e 20 61 72 65 20 61 64 |s sectio|n are ad|
|000060f0| 61 70 74 65 64 20 66 72 | 6f 6d 20 61 20 73 61 6d |apted fr|om a sam|
|00006100| 70 6c 65 20 61 70 70 6c | 69 63 61 74 69 6f 6e 20 |ple appl|ication |
|00006110| 74 68 61 74 20 61 64 64 | 72 65 73 73 65 73 20 74 |that add|resses t|
|00006120| 68 65 20 63 6c 61 73 73 | 69 63 20 63 6f 6d 70 75 |he class|ic compu|
|00006130| 74 65 72 20 73 63 69 65 | 6e 63 65 20 64 69 6e 69 |ter scie|nce dini|
|00006140| 6e 67 20 70 68 69 6c 6f | 73 6f 70 68 65 72 73 20 |ng philo|sophers |
|00006150| 70 72 6f 62 6c 65 6d 2e | 20 54 68 69 73 20 61 70 |problem.| This ap|
|00006160| 70 6c 69 63 61 74 69 6f | 6e 20 75 73 65 73 20 61 |plicatio|n uses a|
|00006170| 20 73 65 70 61 72 61 74 | 65 20 74 68 72 65 61 64 | separat|e thread|
|00006180| 20 74 6f 20 63 6f 6e 74 | 72 6f 6c 20 74 68 65 20 | to cont|rol the |
|00006190| 64 69 73 70 6c 61 79 20 | 61 6e 64 20 6d 6f 76 65 |display |and move|
|000061a0| 6d 65 6e 74 20 6f 66 20 | 65 61 63 68 20 70 68 69 |ment of |each phi|
|000061b0| 6c 6f 73 6f 70 68 65 72 | 20 69 63 6f 6e 20 61 73 |losopher| icon as|
|000061c0| 20 74 68 65 20 70 68 69 | 6c 6f 73 6f 70 68 65 72 | the phi|losopher|
|000061d0| 73 20 6d 6f 76 65 2c 20 | 6f 6e 65 20 62 79 20 6f |s move, |one by o|
|000061e0| 6e 65 2c 20 69 6e 74 6f | 20 61 20 64 69 6e 69 6e |ne, into| a dinin|
|000061f0| 67 20 72 6f 6f 6d 2c 20 | 70 69 63 6b 20 75 70 20 |g room, |pick up |
|00006200| 61 20 66 6f 72 6b 20 65 | 61 74 2c 20 61 6e 64 20 |a fork e|at, and |
|00006210| 74 68 65 6e 20 6c 65 61 | 76 65 20 74 68 65 20 72 |then lea|ve the r|
|00006220| 6f 6f 6d 2e 20 0d 57 68 | 65 6e 20 79 6f 75 72 20 |oom. .Wh|en your |
|00006230| 61 70 70 6c 69 63 61 74 | 69 6f 6e 20 6c 61 75 6e |applicat|ion laun|
|00006240| 63 68 65 73 2c 20 74 68 | 65 20 50 72 6f 63 65 73 |ches, th|e Proces|
|00006250| 73 20 4d 61 6e 61 67 65 | 72 20 61 75 74 6f 6d 61 |s Manage|r automa|
|00006260| 74 69 63 61 6c 6c 79 20 | 63 72 65 61 74 65 73 20 |tically |creates |
|00006270| 74 68 65 20 6d 61 69 6e | 2c 20 6f 72 20 61 70 70 |the main|, or app|
|00006280| 6c 69 63 61 74 69 6f 6e | 2c 20 74 68 72 65 61 64 |lication|, thread|
|00006290| 2e 20 59 6f 75 20 61 72 | 65 20 72 65 73 70 6f 6e |. You ar|e respon|
|000062a0| 73 69 62 6c 65 20 66 6f | 72 20 63 72 65 61 74 69 |sible fo|r creati|
|000062b0| 6e 67 20 61 6e 79 20 61 | 64 64 69 74 69 6f 6e 61 |ng any a|dditiona|
|000062c0| 6c 20 74 68 72 65 61 64 | 73 2e 20 54 68 65 20 6d |l thread|s. The m|
|000062d0| 61 69 6e 20 66 75 6e 63 | 74 69 6f 6e 20 69 73 20 |ain func|tion is |
|000062e0| 74 68 65 20 65 6e 74 72 | 79 20 70 6f 69 6e 74 20 |the entr|y point |
|000062f0| 74 6f 20 74 68 65 20 6d | 61 69 6e 20 74 68 72 65 |to the m|ain thre|
|00006300| 61 64 2e 20 4f 6e 65 20 | 6f 66 20 74 68 65 20 66 |ad. One |of the f|
|00006310| 65 61 74 75 72 65 73 20 | 6f 66 20 74 68 65 20 6d |eatures |of the m|
|00006320| 61 69 6e 20 74 68 72 65 | 61 64 20 69 73 20 74 68 |ain thre|ad is th|
|00006330| 61 74 20 69 74 20 69 73 | 20 74 68 65 20 6f 6e 6c |at it is| the onl|
|00006340| 79 20 74 68 72 65 61 64 | 20 66 72 6f 6d 20 77 68 |y thread| from wh|
|00006350| 69 63 68 20 79 6f 75 20 | 63 61 6e 20 70 72 6f 70 |ich you |can prop|
|00006360| 65 72 6c 79 20 63 61 6c | 6c 20 74 68 65 20 4d 65 |erly cal|l the Me|
|00006370| 6d 6f 72 79 20 4d 61 6e | 61 67 65 72 20 4d 61 78 |mory Man|ager Max|
|00006380| 41 70 70 6c 5a 6f 6e 65 | 20 66 75 6e 63 74 69 6f |ApplZone| functio|
|00006390| 6e 20 74 6f 20 65 78 70 | 61 6e 64 20 79 6f 75 72 |n to exp|and your|
|000063a0| 20 61 70 70 6c 69 63 61 | 74 69 6f 6e 20 68 65 61 | applica|tion hea|
|000063b0| 70 20 74 6f 20 69 74 73 | 20 6c 69 6d 69 74 2e 20 |p to its| limit. |
|000063c0| 59 6f 75 20 6d 75 73 74 | 20 63 61 6c 6c 20 4d 61 |You must| call Ma|
|000063d0| 78 41 70 70 6c 5a 6f 6e | 65 20 62 65 66 6f 72 65 |xApplZon|e before|
|000063e0| 20 61 6e 79 20 6f 74 68 | 65 72 20 74 68 72 65 61 | any oth|er threa|
|000063f0| 64 73 20 72 75 6e 2e 20 | 0d 4c 69 73 74 69 6e 67 |ds run. |.Listing|
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.